From 805ce1d96e6fbe18e2176cabad2b635ded1704ef Mon Sep 17 00:00:00 2001 From: Kieran Date: Fri, 28 Apr 2023 19:26:46 +0100 Subject: [PATCH] bug: prefix hint breaks links --- packages/app/src/Util.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/app/src/Util.ts b/packages/app/src/Util.ts index 70326d5a..8a646122 100644 --- a/packages/app/src/Util.ts +++ b/packages/app/src/Util.ts @@ -523,7 +523,7 @@ export function parseNostrLink(link: string, prefixHint?: NostrPrefix): NostrLin const entity = link.startsWith("web+nostr:") || link.startsWith("nostr:") ? link.split(":")[1] : link; const isPrefix = (prefix: NostrPrefix) => { - return entity.startsWith(prefix) || prefix === prefixHint; + return entity.startsWith(prefix); }; if (isPrefix(NostrPrefix.PublicKey)) { @@ -579,6 +579,14 @@ export function parseNostrLink(link: string, prefixHint?: NostrPrefix): NostrLin encode, }; } + } else if (prefixHint) { + return { + type: prefixHint, + id: link, + encode: () => hexToBech32(prefixHint, link), + }; + } else { + throw new Error("Invalid nostr link"); } }