Support lowercase hashtags when there is Uppercase in post

This commit is contained in:
Niko 2022-02-17 23:13:31 +01:00
parent a59debaa2d
commit d4cf1d92e7
1 changed files with 15 additions and 3 deletions

View File

@ -144,10 +144,22 @@ app.post = {
continue;
if (!hash.match(/^#[a-zA-Z0-9\_]+$/))
continue;
const link = '<a class="hashtag" href="'+htmlescape(href)+'">'+
htmlescape(hash) + '</a>';
hash = hash.trim();
href = href.trim();
const link = '<a class="hashtag" href="'+htmlescape(href)+'">{{hash}}</a>';
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);