diff --git a/src/utils/note.test.ts b/src/utils/note.test.ts
index da922741..39be190b 100644
--- a/src/utils/note.test.ts
+++ b/src/utils/note.test.ts
@@ -32,15 +32,23 @@ Deno.test('parseNoteContent parses mentions with apostrophes', () => {
);
assertEquals(
html,
- `did you see @alex@gleasonator.dev's speech?`,
+ 'did you see @alex@gleasonator.dev's speech?',
);
});
Deno.test("parseNoteContent doesn't parse invalid nostr URIs", () => {
- const { html } = parseNoteContent(`nip19 has URIs like nostr:npub and nostr:nevent, etc.`, []);
+ const { html } = parseNoteContent('nip19 has URIs like nostr:npub and nostr:nevent, etc.', []);
assertEquals(html, 'nip19 has URIs like nostr:npub and nostr:nevent, etc.');
});
+Deno.test('parseNoteContent renders empty for non-profile nostr URIs', () => {
+ const { html } = parseNoteContent(
+ 'nostr:nevent1qgsr9cvzwc652r4m83d86ykplrnm9dg5gwdvzzn8ameanlvut35wy3gpz3mhxue69uhhztnnwashymtnw3ezucm0d5qzqru8mkz2q4gzsxg99q7pdneyx7n8p5u0afe3ntapj4sryxxmg4gpcdvgce',
+ [],
+ );
+ assertEquals(html, '');
+});
+
Deno.test('getMediaLinks', () => {
const links = [
{ href: 'https://example.com/image.png' },
diff --git a/src/utils/note.ts b/src/utils/note.ts
index d64f3dcd..bae371ff 100644
--- a/src/utils/note.ts
+++ b/src/utils/note.ts
@@ -50,9 +50,12 @@ function parseNoteContent(content: string, mentions: MastodonMention[]): ParsedN
const name = mention?.acct ?? npub.substring(0, 8);
const href = mention?.url ?? Conf.local(`/@${acct}`);
return html`@${name}${extra}`;
+ } else {
+ return '';
}
+ } else {
+ return content;
}
- return content;
}
} catch {
// fallthrough