Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit ff175d0

Browse files
Revert "fix: correct STORAGE_EMULATOR_HOST handling (#2069, #1314) (#2070)"
This reverts commit c75b8b8.
1 parent b9fcc09 commit ff175d0

2 files changed

Lines changed: 7 additions & 23 deletions

File tree

src/storage.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -664,12 +664,8 @@ export class Storage extends Service {
664664

665665
options = Object.assign({}, options, {apiEndpoint});
666666

667-
// Note: EMULATOR_HOST, if present and not overridden, has been applied to
668-
// `options` at this point. Also, this uses string concatenation because the
669-
// endpoint may contain a base path, and any trailing slash on that will
670-
// have been removed, so using the two-arg URL constructor for relative path
671-
// resolution won't work.
672-
const baseUrl = new URL(options.apiEndpoint + '/storage/v1').href;
667+
// Note: EMULATOR_HOST is an experimental configuration variable. Use apiEndpoint instead.
668+
const baseUrl = EMULATOR_HOST || `${options.apiEndpoint}/storage/v1`;
673669

674670
const config = {
675671
apiEndpoint: options.apiEndpoint!,

test/index.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -435,33 +435,27 @@ describe('Storage', () => {
435435
delete process.env.STORAGE_EMULATOR_HOST;
436436
});
437437

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

443443
const calledWith = storage.calledWith_[0];
444-
assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST + '/storage/v1');
444+
assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST);
445445
assert.strictEqual(
446446
calledWith.apiEndpoint,
447447
'https://internal.benchmark.com/path'
448448
);
449449
});
450450

451-
it('should be overridden by apiEndpoint', () => {
451+
it('should be overriden by apiEndpoint', () => {
452452
const storage = new Storage({
453453
projectId: PROJECT_ID,
454454
apiEndpoint: 'https://some.api.com',
455455
});
456456

457457
const calledWith = storage.calledWith_[0];
458-
// NOTE: this used to assert partially the opposite of what the test
459-
// says: it checked that baseUrl was _not_ overridden, but apiEndpoint
460-
// was.
461-
assert.strictEqual(
462-
calledWith.baseUrl,
463-
'https://some.api.com/storage/v1'
464-
);
458+
assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST);
465459
assert.strictEqual(calledWith.apiEndpoint, 'https://some.api.com');
466460
});
467461

@@ -474,13 +468,7 @@ describe('Storage', () => {
474468
});
475469

476470
const calledWith = storage.calledWith_[0];
477-
// NOTE: this used to assert partially the opposite of what the test
478-
// says: it checked that baseUrl was _not_ overridden, but apiEndpoint
479-
// was.
480-
assert.strictEqual(
481-
calledWith.baseUrl,
482-
'https://internal.benchmark.com/path/storage/v1'
483-
);
471+
assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST);
484472
assert.strictEqual(
485473
calledWith.apiEndpoint,
486474
'https://internal.benchmark.com/path'

0 commit comments

Comments
 (0)