Skip to content
Snippets Groups Projects
Unverified Commit 0b50feb9 authored by Luís Cobucci's avatar Luís Cobucci Committed by GitHub
Browse files

fix(git-url): clean up state of parsed URL (#24306)


Signed-off-by: default avatarLuís Cobucci <lcobucci@gmail.com>
Co-authored-by: default avatarTobias <github@tobiasgabriel.de>
parent 69e7c80e
No related branches found
No related tags found
No related merge requests found
...@@ -247,7 +247,7 @@ describe('modules/manager/git-submodules/extract', () => { ...@@ -247,7 +247,7 @@ describe('modules/manager/git-submodules/extract', () => {
currentValue: 'main', currentValue: 'main',
depName: 'some-azure', depName: 'some-azure',
packageName: packageName:
'https://organization@dev.azure.com/organization/whitespace%20project/_git/repo', 'https://dev.azure.com/organization/whitespace%20project/_git/repo',
}, },
], ],
}); });
......
...@@ -78,6 +78,21 @@ describe('util/git/url', () => { ...@@ -78,6 +78,21 @@ describe('util/git/url', () => {
'https://x-access-token:token@github.com/some/repo' 'https://x-access-token:token@github.com/some/repo'
); );
}); });
it('removes username/password from URL', () => {
expect(getHttpUrl('https://user:password@foo.bar/someOrg/someRepo')).toBe(
'https://foo.bar/someOrg/someRepo'
);
});
it('replaces username/password with given token', () => {
expect(
getHttpUrl(
'https://user:password@foo.bar/someOrg/someRepo',
'another-user:a-secret-pwd'
)
).toBe('https://another-user:a-secret-pwd@foo.bar/someOrg/someRepo');
});
}); });
describe('getRemoteUrlWithToken()', () => { describe('getRemoteUrlWithToken()', () => {
......
...@@ -15,6 +15,7 @@ export function getHttpUrl(url: string, token?: string): string { ...@@ -15,6 +15,7 @@ export function getHttpUrl(url: string, token?: string): string {
? parsedUrl.protocol ? parsedUrl.protocol
: 'https'; : 'https';
parsedUrl.user = '';
parsedUrl.token = token ?? ''; parsedUrl.token = token ?? '';
if (token) { if (token) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment