Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(search): wrong escape of highlighted tokens
Elian Doranefd294d53bf7
diff --git a/packages/trilium-core/src/services/search/services/search.ts b/packages/trilium-core/src/services/search/services/search.tsindex d699069c53..72f8ef051d 100644--- a/packages/trilium-core/src/services/search/services/search.ts+++ b/packages/trilium-core/src/services/search/services/search.ts@@ -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 matcheshighlightedTokens.sort((a, b) => (a.length > b.length ? -1 : 1));