mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Wrap URL in a try-catch
This commit is contained in:
parent
043e579c10
commit
7a2a8bd4f5
1 changed files with 5 additions and 5 deletions
|
|
@ -33,10 +33,10 @@ function parseNoteContent(content: string, mentions: MastodonMention[]): ParsedN
|
|||
return html`<a class="mention hashtag" href="${href}" rel="tag"><span>#</span>${tag}</a>`;
|
||||
},
|
||||
url: ({ attributes, content }) => {
|
||||
try {
|
||||
const { protocol, pathname } = new URL(content);
|
||||
|
||||
if (protocol === 'nostr:') {
|
||||
try {
|
||||
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`<span class="h-card"><a class="u-url mention" href="${href}" rel="ugc">@<span>${name}</span></a></span>${extra}`;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// fallthrough
|
||||
}
|
||||
return content;
|
||||
} catch {
|
||||
// fallthrough
|
||||
}
|
||||
|
||||
const attr = Object.entries(attributes)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue