forked from nostr/nostrweb
content: parse lightning addresses and render as links
LN addresses use too much screen real estate, render as link seems more useful. lightning links are words starting with the following prefix: lnbc for Bitcoin mainnet, lntb for testnet, lntbs for signet, and lnbcrt for regtest https://github.com/lightning/bolts/blob/master/11-payment-encoding.md#human-readable-part
parent
d7f75f92e0
commit
387f4de3f2
|
@ -59,6 +59,11 @@ export function parseTextContent(string) {
|
|||
.map(line => {
|
||||
const words = line.split(' ');
|
||||
return words.map(word => {
|
||||
if (word.match(/^ln(tbs?|bcr?t?)[a-z0-9]+$/g)) {
|
||||
return elem('a', {
|
||||
href: `lightning:${word}`
|
||||
}, `lightning:${word.slice(0, 24)}…`);
|
||||
}
|
||||
if (!word.match(/(https?:\/\/|www\.)\S*/)) {
|
||||
return word;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue