core: parse internal link from href

This commit is contained in:
Ammar Ahmed
2024-01-24 18:57:34 +05:00
committed by Abdullah Atta
parent 4fc5ec00ae
commit ef6c4bb6fb

View File

@@ -53,8 +53,9 @@ export function createInternalLink<T extends InternalLinkType>(
export function parseInternalLink(link: string): InternalLink | undefined { export function parseInternalLink(link: string): InternalLink | undefined {
const url = new URL(link); const url = new URL(link);
if (url.protocol !== "nn:") return; if (url.protocol !== "nn:") return;
const [type, id] = url.pathname.split("/").slice(2); const [type, id] = url.href.split("?")[0].split("/").slice(2);
if (!type || !id || !isValidInternalType(type)) return; if (!type || !id || !isValidInternalType(type)) return;
return { return {