feed: support nostr:npub uri scheme (part of nip-21)

added support for nostr:npub links in textnotes content.
pull/81/head
OFF0 11 months ago
parent 38591a3b92
commit 027c61e00f
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -1,3 +1,4 @@
import {nip19} from 'nostr-tools';
import {isNotNull} from './array';
import {isValidURL} from './url';
@ -96,6 +97,13 @@ export const parseTextContent = (
href: `lightning:${word}`
}, `lightning:${word.slice(0, 24)}`);
}
if (word.startsWith('nostr:npub') && word.length === 69) {
const npub = word.slice(6);
const {type, data} = nip19.decode(npub);
if (type === 'npub') {
return elem('a', {href: `/${npub}`, data: {profile: data}}, data.slice(6, 15))
}
}
if (!word.match(/^(https?:\/\/|www\.)\S*/)) {
return word;
}

Loading…
Cancel
Save