Merge pull request #15980 from matt-200/master

plugin-azure-devops-backend encoded host breaks readme
This commit is contained in:
Ben Lambert
2023-01-27 10:18:33 +01:00
committed by GitHub
3 changed files with 23 additions and 2 deletions
@@ -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',
);
});
});
@@ -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(