Test and fix parsing of URLs

This commit is contained in:
Alex Gleason 2024-08-28 21:19:07 +02:00
parent 7a2a8bd4f5
commit ba77787767
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 7 additions and 2 deletions

View file

@ -11,10 +11,15 @@ Deno.test('parseNoteContent', () => {
});
Deno.test('parseNoteContent parses URLs', () => {
const { html } = parseNoteContent(`check out my website: https://alexgleason.me`, []);
const { html } = parseNoteContent('check out my website: https://alexgleason.me', []);
assertEquals(html, 'check out my website: <a href="https://alexgleason.me">https://alexgleason.me</a>');
});
Deno.test('parseNoteContent parses bare URLs', () => {
const { html } = parseNoteContent('have you seen ditto.pub?', []);
assertEquals(html, 'have you seen <a href="http://ditto.pub">ditto.pub</a>?');
});
Deno.test('parseNoteContent parses mentions with apostrophes', () => {
const { html } = parseNoteContent(
`did you see nostr:nprofile1qqsqgc0uhmxycvm5gwvn944c7yfxnnxm0nyh8tt62zhrvtd3xkj8fhgprdmhxue69uhkwmr9v9ek7mnpw3hhytnyv4mz7un9d3shjqgcwaehxw309ahx7umywf5hvefwv9c8qtmjv4kxz7gpzemhxue69uhhyetvv9ujumt0wd68ytnsw43z7s3al0v's speech?`,

View file

@ -52,8 +52,8 @@ 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}`;
}
}
return content;
}
return content;
} catch {
// fallthrough
}