Skip to content

Commit 02c2589

Browse files
committed
Improves Azure DevOps issue link generation
Updates the Azure DevOps issue link pattern to correctly handle different project URL structures, ensuring accurate link generation regardless of the URL format. It achieves this by extracting the organization URL from the base URL, providing a consistent way to construct issue links. (#4776, #4777, ..)
1 parent 0281dcf commit 02c2589

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/git/remotes/azure-devops.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type { LocalInfoFromRemoteUriResult, RemoteProviderId } from './remotePro
1414
import { RemoteProvider } from './remoteProvider';
1515

1616
const gitRegex = /\/_git\/?/i;
17+
const gitTailRegex = /\/_git(?:\/.*)?$/i;
1718
const legacyDefaultCollectionRegex = /^DefaultCollection\//i;
1819
const orgAndProjectRegex = /^(.*?)\/(.*?)\/(.*)/;
1920
const sshDomainRegex = /^(ssh|vs-ssh)\./i;
@@ -70,10 +71,9 @@ export class AzureDevOpsRemote extends RemoteProvider {
7071
}
7172

7273
protected override get issueLinkPattern(): string {
73-
if (isVsts(this.domain)) {
74-
return `${this.protocol}://${this.domain}/_workitems/edit/<num>`;
75-
}
76-
return `${this.protocol}://${this.domain}/${this.owner}/_workitems/edit/<num>`;
74+
const projectUrl = this.baseUrl.replace(gitTailRegex, '');
75+
const orgUrl = projectUrl.substring(0, projectUrl.lastIndexOf('/'));
76+
return `${orgUrl}/_workitems/edit/<num>`;
7777
}
7878

7979
private _autolinks: (AutolinkReference | DynamicAutolinkReference)[] | undefined;

0 commit comments

Comments
 (0)