Skip to content

Commit

Permalink
fix: correct STORAGE_EMULATOR_HOST handling (googleapis#2069, googlea…
Browse files Browse the repository at this point in the history
…pis#1314)

credit to @jpambrun for identifying the fix
  • Loading branch information
mgabeler-lee-6rs committed Sep 20, 2022
1 parent 14c4600 commit 5ffa612
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/storage.ts
Expand Up @@ -666,7 +666,7 @@ export class Storage extends Service {
options = Object.assign({}, options, {apiEndpoint});

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

const config = {
apiEndpoint: options.apiEndpoint!,
Expand Down
8 changes: 4 additions & 4 deletions test/index.ts
Expand Up @@ -437,13 +437,13 @@ describe('Storage', () => {
delete process.env.STORAGE_EMULATOR_HOST;
});

it('should set baseUrl to env var STORAGE_EMULATOR_HOST', () => {
it('should set baseUrl to env var STORAGE_EMULATOR_HOST plus standard path', () => {
const storage = new Storage({
projectId: PROJECT_ID,
});

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

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

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

const calledWith = storage.calledWith_[0];
assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST);
assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST + '/storage/v1');
assert.strictEqual(
calledWith.apiEndpoint,
'https://internal.benchmark.com/path'
Expand Down

0 comments on commit 5ffa612

Please sign in to comment.