feed: fix link rendering
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details

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
pull/65/head
OFF0 2 years ago
parent 8ff1d2c1d8
commit a61b54de7c
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -57,14 +57,14 @@ export function parseTextContent(string) {
.replaceAll(/\n{3,}/g, '\n\n') .replaceAll(/\n{3,}/g, '\n\n')
.split('\n') .split('\n')
.map(line => { .map(line => {
const words = line.split(' '); const words = line.split(/\s/);
return words.map(word => { return words.map(word => {
if (word.match(/^ln(tbs?|bcr?t?)[a-z0-9]+$/g)) { if (word.match(/^ln(tbs?|bcr?t?)[a-z0-9]+$/g)) {
return elem('a', { return elem('a', {
href: `lightning:${word}` href: `lightning:${word}`
}, `lightning:${word.slice(0, 24)}`); }, `lightning:${word.slice(0, 24)}`);
} }
if (!word.match(/(https?:\/\/|www\.)\S*/)) { if (!word.match(/^(https?:\/\/|www\.)\S*/)) {
return word; return word;
} }
try { try {

Loading…
Cancel
Save