Skip to content

Commit e60dfad

Browse files
committed
fix(azure-devops): read repository names from URL paths
1 parent 0e03f57 commit e60dfad

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎packages/source-control-azure-devops/src/server/AzureDevOpsSourceControlProvider.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ it.effect("names the remote's repository when reading the default branch", () =>
5555
const provider = yield* AzureDevOpsSourceControlProvider.make;
5656
for (const [remoteUrl, repository] of [
5757
["https://[email protected]/acme/project/_git/My%20Repo", "My Repo"],
58+
["https://dev.azure.com/acme/project/_git/My%20Repo?view=x#readme", "My Repo"],
5859
["https://acme.visualstudio.com/DefaultCollection/project/_git/My%20Repo/", "My Repo"],
5960
["[email protected]:v3/acme/project/My%20Repo", "My Repo"],
61+
["ssh://[email protected]/v3/acme/project/My%20Repo", "My Repo"],
6062
["https://dev.azure.com/acme/project/_git/service.git", "service.git"],
6163
["https://dev.azure.com/acme/project/_git/-repo", "-repo"],
6264
["https://dev.azure.com/acme/project/_git/%40.env", null],

‎packages/source-control-azure-devops/src/server/AzureDevOpsSourceControlProvider.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export const discovery = {
5858
* Azure clone URLs carry no `.git` suffix, so a trailing `.git` is part of the name.
5959
*/
6060
function repositoryNameFromRemote(remoteUrl: string): string | null {
61-
const encoded = remoteUrl.trim().replace(/\/+$/u, "").split(/[/:]/u).at(-1);
61+
const path = URL.parse(remoteUrl.trim())?.pathname ?? remoteUrl.trim();
62+
const encoded = path.replace(/\/+$/u, "").split(/[/:]/u).at(-1);
6263
if (!encoded) return null;
6364
let name = encoded;
6465
try {

0 commit comments

Comments
 (0)