forked from nostr/nostrweb
feed: fix link rendering
some words were incorrectly detected as links. changed: - split words by any whitespace character, not just char 32 - match words _beginning_ with http, https or www. example of broken link user white space character code 160, see: feb290999a2746bf0914ede8a811b52eccd423f9f5373232e4f5947131fb47aa
parent
8ff1d2c1d8
commit
a61b54de7c
|
@ -57,14 +57,14 @@ export function parseTextContent(string) {
|
|||
.replaceAll(/\n{3,}/g, '\n\n')
|
||||
.split('\n')
|
||||
.map(line => {
|
||||
const words = line.split(' ');
|
||||
const words = line.split(/\s/);
|
||||
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*/)) {
|
||||
if (!word.match(/^(https?:\/\/|www\.)\S*/)) {
|
||||
return word;
|
||||
}
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue