diff --git a/src/utils/dom.ts b/src/utils/dom.ts index 686cb49..a39cc86 100644 --- a/src/utils/dom.ts +++ b/src/utils/dom.ts @@ -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; }