Skip to content

Commit b4dbd73

Browse files
authored
fix: Do not set customEndpoint if apiEndpoint === default (#2460)
1 parent 74461e4 commit b4dbd73

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ export class Storage extends Service {
715715
customEndpoint = true;
716716
}
717717

718-
if (options.apiEndpoint) {
718+
if (options.apiEndpoint && options.apiEndpoint !== apiEndpoint) {
719719
apiEndpoint = Storage.sanitizeEndpoint(options.apiEndpoint);
720720
customEndpoint = true;
721721
}

test/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,30 @@ describe('Storage', () => {
174174
assert.strictEqual(calledWith.apiEndpoint, `${apiEndpoint}`);
175175
});
176176

177+
it('should not set `customEndpoint` if `apiEndpoint` matches default', () => {
178+
const apiEndpoint = 'https://storage.googleapis.com';
179+
const storage = new Storage({
180+
apiEndpoint,
181+
});
182+
183+
const calledWith = storage.calledWith_[0];
184+
assert.strictEqual(calledWith.apiEndpoint, apiEndpoint);
185+
assert.strictEqual(calledWith.customEndpoint, false);
186+
});
187+
188+
it('should not set `customEndpoint` if `apiEndpoint` matches default (w/ universe domain)', () => {
189+
const universeDomain = 'my.universe';
190+
const apiEndpoint = `https://storage.${universeDomain}`;
191+
const storage = new Storage({
192+
apiEndpoint,
193+
universeDomain,
194+
});
195+
196+
const calledWith = storage.calledWith_[0];
197+
assert.strictEqual(calledWith.apiEndpoint, apiEndpoint);
198+
assert.strictEqual(calledWith.customEndpoint, false);
199+
});
200+
177201
it('should propagate the useAuthWithCustomEndpoint option', () => {
178202
const useAuthWithCustomEndpoint = true;
179203
const apiEndpoint = 'https://some.fake.endpoint';

0 commit comments

Comments
 (0)