From a61b54de7c15f94e50afe4970ad8ff085232847b Mon Sep 17 00:00:00 2001 From: OFF0 Date: Tue, 17 Jan 2023 09:30:42 +0100 Subject: [PATCH] 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 --- src/domutil.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/domutil.js b/src/domutil.js index 26e2964..bbdb1ee 100644 --- a/src/domutil.js +++ b/src/domutil.js @@ -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 {