mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-23 14:14:33 +00:00
fix(web): build issue popup request from parsed link (#40207)
The issue reference popup built its `/info` request from the raw link path, so a link ending in `/owner/repo/issues/N` queried an unrelated location. It now builds the request from the owner, repo, type and index parsed from the link, with `parseIssueHref` anchored to the pathname under `appSubUrl`.
This commit is contained in:
1 parent
d1c980cf8b
commit
dfe6db6149
3 files changed
+18
-18
No files matched your search
+9
-3
@@ -50,9 +50,15 @@ export function stripTags(text: string): string {
|
||||
}
|
||||
|
||||
export function parseIssueHref(href: string): IssuePathInfo | null {
|
||||
// FIXME: it should use pathname and trim the appSubUrl ahead
|
||||
const path = (href || '').replace(/[#?].*$/, '');
|
||||
const match = /([^/]+)\/([^/]+)\/(issues|pulls)\/([0-9]+)/.exec(path);
|
||||
const {appSubUrl} = window.config;
|
||||
let pathname: string;
|
||||
try {
|
||||
pathname = new URL(href || '', window.location.href).pathname;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
if (!pathname.startsWith(appSubUrl)) return null;
|
||||
const match = /^\/([-.\w]+)\/([-.\w]+)\/(issues|pulls)\/([0-9]+)(?:\/|$)/.exec(pathname.slice(appSubUrl.length));
|
||||
if (!match) return null;
|
||||
const [, ownerName, repoName, pathType, indexString] = match;
|
||||
return {ownerName, repoName, pathType, indexString};
|
||||
|
||||
Reference in new issue
Block a user