Skip to content

Commit

Permalink
Make issue suggestion work for new PR page (go-gitea#33035)
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang authored and GiteaBot committed Dec 31, 2024
1 parent 96fff86 commit f9972e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions web_src/js/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ test('parseIssueNewHref', () => {
expect(parseIssueNewHref('/owner/repo/issues/new')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues'});
expect(parseIssueNewHref('/owner/repo/issues/new?query')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues'});
expect(parseIssueNewHref('/sub/owner/repo/issues/new#hash')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues'});
expect(parseIssueNewHref('/sub/owner/repo/compare/feature/branch-1...fix/branch-2')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'pulls'});
});

test('parseUrl', () => {
Expand Down
5 changes: 3 additions & 2 deletions web_src/js/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ export function parseIssueHref(href: string): IssuePathInfo {

export function parseIssueNewHref(href: string): IssuePathInfo {
const path = (href || '').replace(/[#?].*$/, '');
const [_, ownerName, repoName, pathType, indexString] = /([^/]+)\/([^/]+)\/(issues|pulls)\/new/.exec(path) || [];
return {ownerName, repoName, pathType, indexString};
const [_, ownerName, repoName, pathTypeField] = /([^/]+)\/([^/]+)\/(issues\/new|compare\/.+\.\.\.)/.exec(path) || [];
const pathType = pathTypeField.startsWith('issues/new') ? 'issues' : 'pulls';
return {ownerName, repoName, pathType};
}

export function parseIssuePageInfo(): IssuePageInfo {
Expand Down

0 comments on commit f9972e3

Please sign in to comment.