fix: making the github urls case insensitive

Signed-off-by: Andrew Shoell <mrlunchbox777@gmail.com>
This commit is contained in:
Andrew Shoell
2025-11-13 12:19:21 -05:00
parent ef757315f4
commit e15fdae80f
3 changed files with 28 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/integration': patch
---
making 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}/`;
},
);
}