Merge pull request #31754 from mrlunchbox777/fix-case-sensitive-github-url

fix: making the github urls case insensitive
This commit is contained in:
Ben Lambert
2025-11-25 10:40:47 +01:00
committed by GitHub
3 changed files with 28 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/integration': patch
---
Made the github urls case insensitive.
@@ -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');
});
});
@@ -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}/`;
},
);
}