buildInlineRecipients: delete extra space when there are no inline mentions

This commit is contained in:
Alex Gleason 2023-05-11 20:12:05 -05:00
parent 7820f88859
commit ef5bfb79f0
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 2 additions and 0 deletions

View File

@ -148,6 +148,8 @@ async function toStatus(event: Event<1>) {
type Mention = Awaited<ReturnType<typeof toMention>>; type Mention = Awaited<ReturnType<typeof toMention>>;
function buildInlineRecipients(mentions: Mention[]): string { function buildInlineRecipients(mentions: Mention[]): string {
if (!mentions.length) return '';
const elements = mentions.reduce<string[]>((acc, { url, username }) => { const elements = mentions.reduce<string[]>((acc, { url, username }) => {
const name = nip21.BECH32_REGEX.test(username) ? username.substring(0, 8) : username; const name = nip21.BECH32_REGEX.test(username) ? username.substring(0, 8) : username;
acc.push(`<a href="${url}" class="u-url mention" rel="ugc">@<span>${name}</span></a>`); acc.push(`<a href="${url}" class="u-url mention" rel="ugc">@<span>${name}</span></a>`);