Skip to content

Commit e4c8791

Browse files
committed
fix pathname usage
1 parent a310c88 commit e4c8791

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

web_src/js/utils.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ test('parseIssueHref', () => {
4747

4848
test('parseRepoOwnerPathInfo', () => {
4949
expect(parseRepoOwnerPathInfo('/owner/repo/issues/new')).toEqual({ownerName: 'owner', repoName: 'repo'});
50-
expect(parseRepoOwnerPathInfo('/owner/repo/issues/new?query')).toEqual({ownerName: 'owner', repoName: 'repo'});
5150
expect(parseRepoOwnerPathInfo('/owner/repo/releases')).toEqual({ownerName: 'owner', repoName: 'repo'});
5251
expect(parseRepoOwnerPathInfo('/other')).toEqual({});
5352
window.config.appSubUrl = '/sub';
54-
expect(parseRepoOwnerPathInfo('/sub/owner/repo/issues/new#hash')).toEqual({ownerName: 'owner', repoName: 'repo'});
53+
expect(parseRepoOwnerPathInfo('/sub/owner/repo/issues/new')).toEqual({ownerName: 'owner', repoName: 'repo'});
5554
expect(parseRepoOwnerPathInfo('/sub/owner/repo/compare/feature/branch-1...fix/branch-2')).toEqual({ownerName: 'owner', repoName: 'repo'});
5655
window.config.appSubUrl = '';
5756
});

web_src/js/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ export function parseIssueHref(href: string): IssuePathInfo {
4141
export function parseRepoOwnerPathInfo(pathname: string): RepoOwnerPathInfo {
4242
const appSubUrl = window.config.appSubUrl;
4343
if (appSubUrl && pathname.startsWith(appSubUrl)) pathname = pathname.substring(appSubUrl.length);
44-
const path = (pathname || '').replace(/[#?].*$/, '');
45-
const [_, ownerName, repoName] = /([^/]+)\/([^/]+)/.exec(path) || [];
44+
const [_, ownerName, repoName] = /([^/]+)\/([^/]+)/.exec(pathname) || [];
4645
return {ownerName, repoName};
4746
}
4847

0 commit comments

Comments
 (0)