From d4cf1d92e717ea469b77cee8c40ba18eb2408e89 Mon Sep 17 00:00:00 2001 From: Niko Date: Thu, 17 Feb 2022 23:13:31 +0100 Subject: [PATCH] Support lowercase hashtags when there is Uppercase in post --- web/src/app/js/app.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/web/src/app/js/app.js b/web/src/app/js/app.js index 5acd0f2..3937b92 100644 --- a/web/src/app/js/app.js +++ b/web/src/app/js/app.js @@ -144,10 +144,22 @@ app.post = { continue; if (!hash.match(/^#[a-zA-Z0-9\_]+$/)) continue; - const link = ''+ - htmlescape(hash) + ''; + hash = hash.trim(); + href = href.trim(); + const link = '{{hash}}'; value = value.replaceAll(hash, '\\'+hash); - replaceAfter.push(['\\'+hash, link]); + replaceAfter.push(['\\'+hash, link.replace('{{hash}}', hash)]); + const allhashes = value.match(/#[a-zA-Z0-9\_]+/g); + if (allhashes === undefined || allhashes === null) + continue; + for (var j = 0; j < allhashes.length; j++) { + allhashes[j] = allhashes[j].trim(); + if (allhashes[j].toLowerCase() === hash.toLowerCase() && + allhashes[j] != hash) { + value = value.replaceAll(allhashes[j], '\\'+allhashes[j]); + replaceAfter.push(['\\'+allhashes[j], link.replace('{{hash}}', allhashes[j])]); + } + } } } value = html2text(value);