Skip to content

Commit

Permalink
fix(datasource): re-encode URL to support white spaces in Azure proje…
Browse files Browse the repository at this point in the history
…cts (#23354)
  • Loading branch information
lfcyja committed Jul 19, 2023
1 parent 43551e5 commit ec44118
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/modules/manager/git-submodules/__fixtures__/.gitmodules.6
@@ -0,0 +1,3 @@
[submodule "some-azure"]
path = some-azure
url = https://organization@dev.azure.com/organization/whitespace%20project/_git/repo
24 changes: 24 additions & 0 deletions lib/modules/manager/git-submodules/extract.spec.ts
Expand Up @@ -164,5 +164,29 @@ describe('modules/manager/git-submodules/extract', () => {
],
});
});

it('whitespaces in submodule URL are encoded properly', async () => {
hostRules.add({
matchHost: 'organization@dev.azure.com/organization',
token: 'pat',
hostType: 'azure',
});
gitMock.listRemote.mockResolvedValueOnce(
'ref: refs/heads/main HEAD\n5701164b9f5edba1f6ca114c491a564ffb55a964 HEAD'
);
const res = await extractPackageFile('', '.gitmodules.6', {});
expect(res).toEqual({
datasource: 'git-refs',
deps: [
{
currentDigest: '4b825dc642cb6eb9a060e54bf8d69288fbee4904',
currentValue: 'main',
depName: 'some-azure',
packageName:
'https://organization@dev.azure.com/organization/whitespace%20project/_git/repo',
},
],
});
});
});
});
2 changes: 1 addition & 1 deletion lib/util/git/url.ts
Expand Up @@ -32,7 +32,7 @@ export function getHttpUrl(url: string, token?: string): string {
}
}

return parsedUrl.toString(protocol);
return new URL(parsedUrl.toString(protocol)).href;
}

export function getRemoteUrlWithToken(url: string, hostType?: string): string {
Expand Down

0 comments on commit ec44118

Please sign in to comment.