Skip to content

Commit

Permalink
fix: Do not set customEndpoint if apiEndpoint === default (#2460)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-goog authored May 8, 2024
1 parent 74461e4 commit b4dbd73
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ export class Storage extends Service {
customEndpoint = true;
}

if (options.apiEndpoint) {
if (options.apiEndpoint && options.apiEndpoint !== apiEndpoint) {
apiEndpoint = Storage.sanitizeEndpoint(options.apiEndpoint);
customEndpoint = true;
}
Expand Down
24 changes: 24 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,30 @@ describe('Storage', () => {
assert.strictEqual(calledWith.apiEndpoint, `${apiEndpoint}`);
});

it('should not set `customEndpoint` if `apiEndpoint` matches default', () => {
const apiEndpoint = 'https://storage.googleapis.com';
const storage = new Storage({
apiEndpoint,
});

const calledWith = storage.calledWith_[0];
assert.strictEqual(calledWith.apiEndpoint, apiEndpoint);
assert.strictEqual(calledWith.customEndpoint, false);
});

it('should not set `customEndpoint` if `apiEndpoint` matches default (w/ universe domain)', () => {
const universeDomain = 'my.universe';
const apiEndpoint = `https://storage.${universeDomain}`;
const storage = new Storage({
apiEndpoint,
universeDomain,
});

const calledWith = storage.calledWith_[0];
assert.strictEqual(calledWith.apiEndpoint, apiEndpoint);
assert.strictEqual(calledWith.customEndpoint, false);
});

it('should propagate the useAuthWithCustomEndpoint option', () => {
const useAuthWithCustomEndpoint = true;
const apiEndpoint = 'https://some.fake.endpoint';
Expand Down

0 comments on commit b4dbd73

Please sign in to comment.