( provider: Provider, repositoryName: string, host?: string | null, )
| 320 | * constructRepositoryUrl("azure_devops", "org/Web Apps/repo") // "https://dev.azure.com/org/Web%20Apps/_git/repo" |
| 321 | */ |
| 322 | export const constructRepositoryUrl = ( |
| 323 | provider: Provider, |
| 324 | repositoryName: string, |
| 325 | host?: string | null, |
| 326 | ): string => { |
| 327 | const baseUrl = getGitProviderBaseUrl(provider, host); |
| 328 | if (provider === "bitbucket_data_center") { |
| 329 | const [project, repo] = repositoryName.split("/").map(encodePathSegment); |
| 330 | return `${baseUrl}/projects/${project}/repos/${repo}`; |
| 331 | } |
| 332 | if (provider === "azure_devops") { |
| 333 | // Azure DevOps format: org/project/repo |
| 334 | const parts = repositoryName.split("/"); |
| 335 | if (parts.length === 3) { |
| 336 | const [org, project, repo] = parts.map(encodePathSegment); |
| 337 | return `${baseUrl}/${org}/${project}/_git/${repo}`; |
| 338 | } |
| 339 | } |
| 340 | return `${baseUrl}/${encodeRepositoryPath(repositoryName)}`; |
| 341 | }; |
| 342 | |
| 343 | /** |
| 344 | * Percent-encode a branch name for use as a URL path component. Each |
no test coverage detected