From 53964d196d8a517f30fc2485b620b36c9890c6ff Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 27 Oct 2021 16:49:36 +0200 Subject: [PATCH] fix(gomod): remove token encoding (#12352) Co-authored-by: Rhys Arkins --- lib/util/git/auth.spec.ts | 7 ++++--- lib/util/git/auth.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/util/git/auth.spec.ts b/lib/util/git/auth.spec.ts index 7e54bf89aa50b1..6e3d5690a8a746 100644 --- a/lib/util/git/auth.spec.ts +++ b/lib/util/git/auth.spec.ts @@ -18,14 +18,15 @@ describe('util/git/auth', () => { }); }); - it('returns url with correctly encoded token', () => { + it('returns correct url if token already contains GitHub App username', () => { expect( getGitAuthenticatedEnvironmentVariables( 'https://github.com/', - 'token:1234' + 'x-access-token:token1234' ) ).toStrictEqual({ - GIT_CONFIG_KEY_0: 'url.https://token%3A1234@github.com/.insteadOf', + GIT_CONFIG_KEY_0: + 'url.https://x-access-token:token1234@github.com/.insteadOf', GIT_CONFIG_VALUE_0: 'https://github.com/', GIT_CONFIG_COUNT: '1', }); diff --git a/lib/util/git/auth.ts b/lib/util/git/auth.ts index 3a6c56b2185fb6..fd5dd855ab1e9c 100644 --- a/lib/util/git/auth.ts +++ b/lib/util/git/auth.ts @@ -24,7 +24,7 @@ export function getGitAuthenticatedEnvironmentVariables( } } - const gitUrlWithToken = getHttpUrl(gitUrl, encodeURIComponent(token)); + const gitUrlWithToken = getHttpUrl(gitUrl, token); // create a shallow copy of the environmentVariables as base so we don't modify the input parameter object // add the two new config key and value to the returnEnvironmentVariables object