From bce8eb1bfffb6672a4c7dca395c5450dff0c8b9e Mon Sep 17 00:00:00 2001 From: matt-200 <123186429+matt-200@users.noreply.github.com> Date: Wed, 25 Jan 2023 17:50:04 -0600 Subject: [PATCH 1/7] Remove host encoding Fixes bug #15874 Signed-off-by: matt-200 <123186429+matt-200@users.noreply.github.com> --- plugins/azure-devops-backend/src/utils/azure-devops-utils.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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( From cc926a59bd11834850ed1678cdd93b9edeb5c6a8 Mon Sep 17 00:00:00 2001 From: matt-200 <123186429+matt-200@users.noreply.github.com> Date: Wed, 25 Jan 2023 18:20:51 -0600 Subject: [PATCH 2/7] Add changeset Happy cows moo! Signed-off-by: matt-200 <123186429+matt-200@users.noreply.github.com> --- .changeset/happy-cows-moo.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/happy-cows-moo.md diff --git a/.changeset/happy-cows-moo.md b/.changeset/happy-cows-moo.md new file mode 100644 index 0000000000..e59d9a72d0 --- /dev/null +++ b/.changeset/happy-cows-moo.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-azure-devops-backend': patch +--- + +Fixed a bug in buildEncodedUrl function where port was being encoded and breaking the readme card From 21a7b9fd83b7c70dac25de66b497e79f9299d03f Mon Sep 17 00:00:00 2001 From: matt-200 <123186429+matt-200@users.noreply.github.com> Date: Wed, 25 Jan 2023 18:34:14 -0600 Subject: [PATCH 3/7] Add a test for buildEncodedUrl Protect against regression Signed-off-by: matt-200 <123186429+matt-200@users.noreply.github.com> --- .../src/utils/azure-devops-utils.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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..ba288dad95 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 @@ -278,3 +278,17 @@ 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'); + }); +}); From 09547ac9647390cf64e17a95557bc4c71dda58ce Mon Sep 17 00:00:00 2001 From: matt-200 <123186429+matt-200@users.noreply.github.com> Date: Wed, 25 Jan 2023 18:59:20 -0600 Subject: [PATCH 4/7] Ran npx prettier --write . It looks better now. Signed-off-by: matt-200 <123186429+matt-200@users.noreply.github.com> --- .../src/utils/azure-devops-utils.test.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 ba288dad95..355919dc55 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 @@ -281,14 +281,16 @@ describe('replaceReadme', () => { describe('buildEncodedUrl', () => { it('should not encode the colon between host and port', async () => { - const result = await buildEncodedUrl( + const result = await buildEncodedUrl( 'tfs.myorg.com:8443', 'org', 'project', 'repo', - 'path' + 'path', + ); + + expect(result).toBe( + 'https://tfs.myorg.com:8443/org/project/_git/repo?path=path', ); - - expect(result).toBe('https://tfs.myorg.com:8443/org/project/_git/repo?path=path'); }); }); From d015fe1f7ea4f92fb59a729351336438b57cd9cf Mon Sep 17 00:00:00 2001 From: matt-200 <123186429+matt-200@users.noreply.github.com> Date: Wed, 25 Jan 2023 19:09:18 -0600 Subject: [PATCH 5/7] Slight tweak Was missing some words Signed-off-by: matt-200 <123186429+matt-200@users.noreply.github.com> --- .changeset/happy-cows-moo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/happy-cows-moo.md b/.changeset/happy-cows-moo.md index e59d9a72d0..69a8d9d4f5 100644 --- a/.changeset/happy-cows-moo.md +++ b/.changeset/happy-cows-moo.md @@ -2,4 +2,4 @@ '@backstage/plugin-azure-devops-backend': patch --- -Fixed a bug in buildEncodedUrl function where port was being encoded and breaking the readme card +Fixed a bug in buildEncodedUrl function where the colon between host name and port was being encoded and breaking the readme card From 9d0900ee0b6326e8577a03c72a29537e804ca6b2 Mon Sep 17 00:00:00 2001 From: matt-200 <123186429+matt-200@users.noreply.github.com> Date: Thu, 26 Jan 2023 08:21:27 -0600 Subject: [PATCH 6/7] Slight tweak to changeset file Make it clearer Signed-off-by: matt-200 <123186429+matt-200@users.noreply.github.com> --- .changeset/happy-cows-moo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/happy-cows-moo.md b/.changeset/happy-cows-moo.md index 69a8d9d4f5..a5e425f5d2 100644 --- a/.changeset/happy-cows-moo.md +++ b/.changeset/happy-cows-moo.md @@ -2,4 +2,4 @@ '@backstage/plugin-azure-devops-backend': patch --- -Fixed a bug in buildEncodedUrl function where the colon between host name and port was being encoded and breaking the readme card +Fixed a bug where the azure devops host in URLs on the readme card was being URL encoded, breaking hosts with ports. From 0aeeafe7a7c2b0065f9f54cf04a4fb0ba8d91f86 Mon Sep 17 00:00:00 2001 From: matt-200 <123186429+matt-200@users.noreply.github.com> Date: Thu, 26 Jan 2023 08:22:35 -0600 Subject: [PATCH 7/7] Add missing import Forgot the import Signed-off-by: matt-200 <123186429+matt-200@users.noreply.github.com> --- .../azure-devops-backend/src/utils/azure-devops-utils.test.ts | 1 + 1 file changed, 1 insertion(+) 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 355919dc55..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';