Skip to content

Commit 4e4badf

Browse files
authored
fix: strip trailing slashes from automatic GDCH audience (#8692)
Follow up PR to https://togithub.com/googleapis/google-cloud-node/pull/8301 Fixes https://togithub.com/googleapis/google-cloud-node/issues/8289 See testing in [go/gemini-cli-sa](http://goto.google.com/gemini-cli-sa)
1 parent ed701c6 commit 4e4badf

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

core/packages/google-auth-library-nodejs/src/auth/googleauth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ export class GoogleAuth<T extends AuthClient = AuthClient> {
11551155
const endpoint = opts.apiEndpoint || opts.servicePath;
11561156
if (endpoint) {
11571157
const scheme = endpoint.startsWith('http') ? '' : 'https://';
1158-
const formattedAudience = `${scheme}${endpoint}/`.replace(/\/+$/, '/');
1158+
const formattedAudience = `${scheme}${endpoint}`.replace(/\/+$/, '');
11591159
const newClient = client.createWithGdchAudience(formattedAudience);
11601160
this.cachedCredential = newClient;
11611161
return newClient;

core/packages/google-auth-library-nodejs/test/test.googleauth.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,7 +3032,7 @@ describe('googleauth', () => {
30323032
assert.ok(client instanceof GdchClient);
30333033
assert.strictEqual(
30343034
(client as GdchClient).apiAudience,
3035-
'https://hardwaremanagement.us-west1.gdch.google.com/'
3035+
'https://hardwaremanagement.us-west1.gdch.google.com'
30363036
);
30373037
});
30383038

@@ -3048,7 +3048,7 @@ describe('googleauth', () => {
30483048
assert.ok(client instanceof GdchClient);
30493049
assert.strictEqual(
30503050
(client as GdchClient).apiAudience,
3051-
'https://hardwaremanagement.us-west1.gdch.google.com/'
3051+
'https://hardwaremanagement.us-west1.gdch.google.com'
30523052
);
30533053
});
30543054

@@ -3064,7 +3064,7 @@ describe('googleauth', () => {
30643064
assert.ok(client instanceof GdchClient);
30653065
assert.strictEqual(
30663066
(client as GdchClient).apiAudience,
3067-
'http://hardwaremanagement.us-west1.gdch.google.com/'
3067+
'http://hardwaremanagement.us-west1.gdch.google.com'
30683068
);
30693069
});
30703070

0 commit comments

Comments
 (0)