diff --git a/core/packages/google-auth-library-nodejs/src/auth/googleauth.ts b/core/packages/google-auth-library-nodejs/src/auth/googleauth.ts index 86e4cb4dd358..b032b4efb37c 100644 --- a/core/packages/google-auth-library-nodejs/src/auth/googleauth.ts +++ b/core/packages/google-auth-library-nodejs/src/auth/googleauth.ts @@ -1155,7 +1155,7 @@ export class GoogleAuth { const endpoint = opts.apiEndpoint || opts.servicePath; if (endpoint) { const scheme = endpoint.startsWith('http') ? '' : 'https://'; - const formattedAudience = `${scheme}${endpoint}/`.replace(/\/+$/, '/'); + const formattedAudience = `${scheme}${endpoint}`.replace(/\/+$/, ''); const newClient = client.createWithGdchAudience(formattedAudience); this.cachedCredential = newClient; return newClient; diff --git a/core/packages/google-auth-library-nodejs/test/test.googleauth.ts b/core/packages/google-auth-library-nodejs/test/test.googleauth.ts index 350b326be6e4..4b2e44b97e16 100644 --- a/core/packages/google-auth-library-nodejs/test/test.googleauth.ts +++ b/core/packages/google-auth-library-nodejs/test/test.googleauth.ts @@ -3032,7 +3032,7 @@ describe('googleauth', () => { assert.ok(client instanceof GdchClient); assert.strictEqual( (client as GdchClient).apiAudience, - 'https://hardwaremanagement.us-west1.gdch.google.com/' + 'https://hardwaremanagement.us-west1.gdch.google.com' ); }); @@ -3048,7 +3048,7 @@ describe('googleauth', () => { assert.ok(client instanceof GdchClient); assert.strictEqual( (client as GdchClient).apiAudience, - 'https://hardwaremanagement.us-west1.gdch.google.com/' + 'https://hardwaremanagement.us-west1.gdch.google.com' ); }); @@ -3064,7 +3064,7 @@ describe('googleauth', () => { assert.ok(client instanceof GdchClient); assert.strictEqual( (client as GdchClient).apiAudience, - 'http://hardwaremanagement.us-west1.gdch.google.com/' + 'http://hardwaremanagement.us-west1.gdch.google.com' ); });