diff --git a/.changeset/happy-cows-moo.md b/.changeset/happy-cows-moo.md new file mode 100644 index 0000000000..a5e425f5d2 --- /dev/null +++ b/.changeset/happy-cows-moo.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-azure-devops-backend': patch +--- + +Fixed a bug where the azure devops host in URLs on the readme card was being URL encoded, breaking hosts with ports. diff --git a/plugins/azure-devops-backend/src/utils/azure-devops-utils.test.ts b/plugins/azure-devops-backend/src/utils/azure-devops-utils.test.ts index 4b912a8340..427980be14 100644 --- a/plugins/azure-devops-backend/src/utils/azure-devops-utils.test.ts +++ b/plugins/azure-devops-backend/src/utils/azure-devops-utils.test.ts @@ -27,6 +27,7 @@ import { getAvatarUrl, getPullRequestLink, replaceReadme, + buildEncodedUrl, } from './azure-devops-utils'; import { GitPullRequest } from 'azure-devops-node-api/interfaces/GitInterfaces'; import { UrlReader } from '@backstage/backend-common'; @@ -278,3 +279,19 @@ describe('replaceReadme', () => { expect(expected).toBe(result); }); }); + +describe('buildEncodedUrl', () => { + it('should not encode the colon between host and port', async () => { + const result = await buildEncodedUrl( + 'tfs.myorg.com:8443', + 'org', + 'project', + 'repo', + 'path', + ); + + expect(result).toBe( + 'https://tfs.myorg.com:8443/org/project/_git/repo?path=path', + ); + }); +}); diff --git a/plugins/azure-devops-backend/src/utils/azure-devops-utils.ts b/plugins/azure-devops-backend/src/utils/azure-devops-utils.ts index 0aafb54a0a..aa946e7a74 100644 --- a/plugins/azure-devops-backend/src/utils/azure-devops-utils.ts +++ b/plugins/azure-devops-backend/src/utils/azure-devops-utils.ts @@ -242,12 +242,11 @@ export function buildEncodedUrl( repo: string, path: string, ): string { - const encodedHost = encodeURIComponent(host); const encodedOrg = encodeURIComponent(org); const encodedProject = encodeURIComponent(project); const encodedRepo = encodeURIComponent(repo); const encodedPath = encodeURIComponent(path); - return `https://${encodedHost}/${encodedOrg}/${encodedProject}/_git/${encodedRepo}?path=${encodedPath}`; + return `https://${host}/${encodedOrg}/${encodedProject}/_git/${encodedRepo}?path=${encodedPath}`; } function convertReviewer(