Implement Azure DevOps URL parsing for repositories

Added support for Azure DevOps URL parsing, including both modern and legacy formats, to extract relevant repository information.
This commit is contained in:
Tankatronic 2026-04-15 12:13:49 -07:00 committed by Justin Loveless
parent 87292cd86a
commit 658261aef5
1 changed files with 50 additions and 0 deletions

View File

@ -73,6 +73,56 @@ class CustomModuleManager {
}; };
} }
// Azure DevOps URL: https://dev.azure.com/{org}/{project}/_git/{repo}
// Also supports legacy: https://{org}.visualstudio.com/{project}/_git/{repo}
const adoModernMatch = trimmed.match(
/^https?:\/\/(dev\.azure\.com)\/([^/]+)\/([^/]+)\/_git\/([^/.]+?)(?:\.git)?(\/.*)?$/,
);
const adoLegacyMatch =
!adoModernMatch &&
trimmed.match(
/^https?:\/\/([^/]+\.visualstudio\.com)\/([^/]+)\/_git\/([^/.]+?)(?:\.git)?(\/.*)?$/,
);
const adoMatch = adoModernMatch || adoLegacyMatch;
if (adoMatch) {
let host, org, project, repo, remainder;
if (adoModernMatch) {
[, host, org, project, repo, remainder] = adoModernMatch;
} else {
// Legacy: org is in the hostname, path is /{project}/_git/{repo}
[, host, project, repo, remainder] = adoLegacyMatch;
org = null;
}
const cloneUrl = adoModernMatch
? `https://${host}/${org}/${project}/_git/${repo}`
: `https://${host}/${project}/_git/${repo}`;
let subdir = null;
if (remainder) {
// Azure DevOps uses ?path=/subdir or /path/subdir patterns
const subdirMatch = remainder.match(/^\/(.+)$/);
if (subdirMatch) {
subdir = subdirMatch[1].replace(/\/$/, '');
}
}
const cacheKey = adoModernMatch
? `${host}/${org}/${project}/${repo}`
: `${host}/${project}/${repo}`;
return {
type: 'url',
cloneUrl,
subdir,
localPath: null,
cacheKey,
displayName: `${project}/${repo}`,
isValid: true,
error: null,
};
}
// HTTPS URL: https://host/owner/repo[/tree/branch/subdir][.git] // HTTPS URL: https://host/owner/repo[/tree/branch/subdir][.git]
const httpsMatch = trimmed.match(/^https?:\/\/([^/]+)\/([^/]+)\/([^/.]+?)(?:\.git)?(\/.*)?$/); const httpsMatch = trimmed.match(/^https?:\/\/([^/]+)\/([^/]+)\/([^/.]+?)(?:\.git)?(\/.*)?$/);
if (httpsMatch) { if (httpsMatch) {