Skip to content

Commit 5ffa612

Browse files
fix: correct STORAGE_EMULATOR_HOST handling (googleapis#2069, googleapis#1314)
credit to @jpambrun for identifying the fix
1 parent 14c4600 commit 5ffa612

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎src/storage.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ export class Storage extends Service {
666666
options = Object.assign({}, options, {apiEndpoint});
667667

668668
// Note: EMULATOR_HOST is an experimental configuration variable. Use apiEndpoint instead.
669-
const baseUrl = EMULATOR_HOST || `${options.apiEndpoint}/storage/v1`;
669+
const baseUrl = (EMULATOR_HOST || options.apiEndpoint) + '/storage/v1';
670670

671671
const config = {
672672
apiEndpoint: options.apiEndpoint!,

‎test/index.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,13 +437,13 @@ describe('Storage', () => {
437437
delete process.env.STORAGE_EMULATOR_HOST;
438438
});
439439

440-
it('should set baseUrl to env var STORAGE_EMULATOR_HOST', () => {
440+
it('should set baseUrl to env var STORAGE_EMULATOR_HOST plus standard path', () => {
441441
const storage = new Storage({
442442
projectId: PROJECT_ID,
443443
});
444444

445445
const calledWith = storage.calledWith_[0];
446-
assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST);
446+
assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST + '/storage/v1');
447447
assert.strictEqual(
448448
calledWith.apiEndpoint,
449449
'https://internal.benchmark.com/path'
@@ -457,7 +457,7 @@ describe('Storage', () => {
457457
});
458458

459459
const calledWith = storage.calledWith_[0];
460-
assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST);
460+
assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST + '/storage/v1');
461461
assert.strictEqual(calledWith.apiEndpoint, 'https://some.api.com');
462462
});
463463

@@ -470,7 +470,7 @@ describe('Storage', () => {
470470
});
471471

472472
const calledWith = storage.calledWith_[0];
473-
assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST);
473+
assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST + '/storage/v1');
474474
assert.strictEqual(
475475
calledWith.apiEndpoint,
476476
'https://internal.benchmark.com/path'

0 commit comments

Comments
 (0)