fix: making the github urls case insensitive
Signed-off-by: Andrew Shoell <mrlunchbox777@gmail.com>
This commit is contained in:
@@ -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}/`;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user