diff --git a/nostr.ts b/nostr.ts index 7d1884c..7ea7ace 100644 --- a/nostr.ts +++ b/nostr.ts @@ -107,15 +107,13 @@ export async function nostrUriToUrl(uri: string): Promise { } export async function replaceNostrUris(markdown: string): Promise { - const nostrUriRegex = - /\((nostr:|nprofile|naddr|nevent|nrelay|npub)[a-z0-9]+\)/g; + const nostrUriRegex = /(nostr:|nprofile|naddr|nevent|nrelay|npub)[a-z0-9]+/g; const matches = markdown.match(nostrUriRegex); if (!matches) return markdown; - for (const match of matches) { - const uri = match.slice(1, -1); + for (const uri of matches) { const url = await nostrUriToUrl(uri); - markdown = markdown.replace(match, `(${url})`); + markdown = markdown.replace(uri, url); } return markdown; @@ -133,11 +131,7 @@ export async function verifyNip05Address( if (res.status === 404 || !res.ok) return false; const data = await res.json(); - if (data.names && data.names[username] === pubkey) { - return true; - } else { - return false; - } + return data.names && data.names[username] === pubkey; } catch (_e) { return false; }