fix: Allow backlinks to work with fully qualified urls and anchors (#4050)

closes #4048
This commit is contained in:
Tom Moor
2022-09-04 09:14:21 +02:00
committed by GitHub
parent e1b0e94fd5
commit e0e87ea6a2
3 changed files with 34 additions and 17 deletions

View File

@@ -1,3 +1,9 @@
/**
* Parse the likely document identifier from a given url.
*
* @param url The url to parse.
* @returns A document identifier or undefined if not found.
*/
export default function parseDocumentSlug(url: string) {
let parsed;
@@ -12,6 +18,6 @@ export default function parseDocumentSlug(url: string) {
}
return parsed.lastIndexOf("/doc/") === 0
? parsed.replace(/^\/doc\//, "")
: null;
? parsed.replace(/^\/doc\//, "").split("#")[0]
: undefined;
}