fix: 🐛 prevent html tags to be highlighted

This commit is contained in:
HannesOberreiter 2023-06-25 20:13:18 +02:00
parent cb38e6c5c1
commit 495571b8a7

View File

@ -212,7 +212,8 @@ class ItemsList extends View {
let highlightedName = name;
for (let i = 0; i < keywords.length; i++) {
const string = keywords[i];
const regex = new RegExp(string, "gi");
// check if keyword is not preceded by a < or </
const regex = new RegExp(`(?<!<\/?)${string}`, "gi");
highlightedName = highlightedName.replace(regex, "<strong>$&</strong>");
}
return `${highlightedName}`;