forked from nostr/nostrweb
feed: support nostr:npub uri scheme (part of nip-21)
added support for nostr:npub links in textnotes content.
parent
38591a3b92
commit
027c61e00f
src/utils
|
@ -1,3 +1,4 @@
|
||||||
|
import {nip19} from 'nostr-tools';
|
||||||
import {isNotNull} from './array';
|
import {isNotNull} from './array';
|
||||||
import {isValidURL} from './url';
|
import {isValidURL} from './url';
|
||||||
|
|
||||||
|
@ -96,6 +97,13 @@ export const parseTextContent = (
|
||||||
href: `lightning:${word}`
|
href: `lightning:${word}`
|
||||||
}, `lightning:${word.slice(0, 24)}…`);
|
}, `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*/)) {
|
if (!word.match(/^(https?:\/\/|www\.)\S*/)) {
|
||||||
return word;
|
return word;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue