From e15fdae80f7d90f1a509a833f3de09f6c6054d82 Mon Sep 17 00:00:00 2001 From: Andrew Shoell Date: Thu, 13 Nov 2025 12:19:21 -0500 Subject: [PATCH] fix: making the github urls case insensitive Signed-off-by: Andrew Shoell --- .changeset/kind-hoops-double.md | 5 +++++ .../src/github/GithubIntegration.test.ts | 20 +++++++++++++++++++ .../src/github/GithubIntegration.ts | 4 +++- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 .changeset/kind-hoops-double.md diff --git a/.changeset/kind-hoops-double.md b/.changeset/kind-hoops-double.md new file mode 100644 index 0000000000..fffe7986ba --- /dev/null +++ b/.changeset/kind-hoops-double.md @@ -0,0 +1,5 @@ +--- +'@backstage/integration': patch +--- + +making the github urls case insensitive diff --git a/packages/integration/src/github/GithubIntegration.test.ts b/packages/integration/src/github/GithubIntegration.test.ts index 70f1c4a16c..c54d4db2ef 100644 --- a/packages/integration/src/github/GithubIntegration.test.ts +++ b/packages/integration/src/github/GithubIntegration.test.ts @@ -134,4 +134,24 @@ describe('replaceGithubUrlType', () => { ), ).toBe('https://github.com/backstage/backstage/blob/tree/README.md'); }); + it('should replace with lowercase', () => { + expect( + replaceGithubUrlType( + 'https://githuB.com/backstage/backstage/blob/master/README.md', + 'edit', + ), + ).toBe('https://github.com/backstage/backstage/edit/master/README.md'); + expect( + replaceGithubUrlType( + 'https://github.com/Backstage/backstage/blob/master/README.md', + 'edit', + ), + ).toBe('https://github.com/backstage/backstage/edit/master/README.md'); + expect( + replaceGithubUrlType( + 'https://github.com/backstage/Backstage/blob/master/README.md', + 'edit', + ), + ).toBe('https://github.com/backstage/backstage/edit/master/README.md'); + }); }); diff --git a/packages/integration/src/github/GithubIntegration.ts b/packages/integration/src/github/GithubIntegration.ts index 880a2bed21..79d5e7f421 100644 --- a/packages/integration/src/github/GithubIntegration.ts +++ b/packages/integration/src/github/GithubIntegration.ts @@ -95,7 +95,9 @@ export function replaceGithubUrlType( return url.replace( /\/\/([^/]+)\/([^/]+)\/([^/]+)\/(blob|tree|edit)\//, (_, host, owner, repo) => { - return `//${host}/${owner}/${repo}/${type}/`; + return `//${host.toLocaleLowerCase('en-US')}/${owner.toLocaleLowerCase( + 'en-US', + )}/${repo.toLocaleLowerCase('en-US')}/${type}/`; }, ); }