fix(search): wrong escape of highlighted tokens

This commit is contained in:
Elian Doran
2026-03-22 21:52:14 +02:00
parent f9eb4bf574
commit efd294d53b

View File

@@ -691,7 +691,7 @@ function highlightSearchResults(searchResults: SearchResult[], highlightedTokens
// which would make the resulting HTML string invalid.
// { and } are used for marking <b> and </b> tag (to avoid matches on single 'b' character)
// < and > are used for marking <small> and </small>
highlightedTokens = highlightedTokens.map((token) => token.replace("/[<\{\}]/g", "")).filter((token) => !!token?.trim());
highlightedTokens = highlightedTokens.map((token) => token.replace(/[<>{}]/g, "")).filter((token) => !!token?.trim());
// sort by the longest, so we first highlight the longest matches
highlightedTokens.sort((a, b) => (a.length > b.length ? -1 : 1));