Link plain Nostr URIs
Not just explicit Markdown links
This commit is contained in:
parent
010eb3f291
commit
5f38355d5c
14
nostr.ts
14
nostr.ts
@ -107,15 +107,13 @@ export async function nostrUriToUrl(uri: string): Promise<string> {
|
||||
}
|
||||
|
||||
export async function replaceNostrUris(markdown: string): Promise<string> {
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user