From 7a2a8bd4f52717f19c970e91803d166070bcbc24 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 28 Aug 2024 21:15:43 +0200 Subject: [PATCH] Wrap URL in a try-catch --- src/utils/note.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/note.ts b/src/utils/note.ts index 1dfa08a1..b0b075d9 100644 --- a/src/utils/note.ts +++ b/src/utils/note.ts @@ -33,10 +33,10 @@ function parseNoteContent(content: string, mentions: MastodonMention[]): ParsedN return html``; }, url: ({ attributes, content }) => { - const { protocol, pathname } = new URL(content); + try { + const { protocol, pathname } = new URL(content); - if (protocol === 'nostr:') { - try { + if (protocol === 'nostr:') { const match = pathname.match(new RegExp(`^${nip19.BECH32_REGEX.source}`)); if (match) { const bech32 = match[0]; @@ -52,10 +52,10 @@ function parseNoteContent(content: string, mentions: MastodonMention[]): ParsedN return html`@${name}${extra}`; } } - } catch { - // fallthrough } return content; + } catch { + // fallthrough } const attr = Object.entries(attributes)