From 9a7702b85be2636d4a0810ea70a3dd08e6fcec06 Mon Sep 17 00:00:00 2001 From: Jerry Lin Date: Sun, 21 Jun 2026 00:56:05 +0000 Subject: [PATCH] fix: strip trailing slashes from automatic GDCH audience --- .../google-auth-library-nodejs/src/auth/googleauth.ts | 2 +- .../google-auth-library-nodejs/test/test.googleauth.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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' ); });