mirror of
https://github.com/go-gitea/gitea
synced 2025-01-07 00:14:25 +00:00
parent
4a254856b3
commit
c09656e0e0
@ -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')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues'});
|
||||||
expect(parseIssueNewHref('/owner/repo/issues/new?query')).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/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', () => {
|
test('parseUrl', () => {
|
||||||
|
@ -39,8 +39,9 @@ export function parseIssueHref(href: string): IssuePathInfo {
|
|||||||
|
|
||||||
export function parseIssueNewHref(href: string): IssuePathInfo {
|
export function parseIssueNewHref(href: string): IssuePathInfo {
|
||||||
const path = (href || '').replace(/[#?].*$/, '');
|
const path = (href || '').replace(/[#?].*$/, '');
|
||||||
const [_, ownerName, repoName, pathType, indexString] = /([^/]+)\/([^/]+)\/(issues|pulls)\/new/.exec(path) || [];
|
const [_, ownerName, repoName, pathTypeField] = /([^/]+)\/([^/]+)\/(issues\/new|compare\/.+\.\.\.)/.exec(path) || [];
|
||||||
return {ownerName, repoName, pathType, indexString};
|
const pathType = pathTypeField.startsWith('issues/new') ? 'issues' : 'pulls';
|
||||||
|
return {ownerName, repoName, pathType};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseIssuePageInfo(): IssuePageInfo {
|
export function parseIssuePageInfo(): IssuePageInfo {
|
||||||
|
Loading…
Reference in New Issue
Block a user