From 9881e6de3e4966af39ec6245562dca6ac7b25eaa Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 26 Mar 2023 23:09:15 +0200 Subject: [PATCH] fix hangup on highlighting empty tokens, closes #3772 --- src/services/search/services/search.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/search/services/search.js b/src/services/search/services/search.js index beb0555d1..d682af090 100644 --- a/src/services/search/services/search.js +++ b/src/services/search/services/search.js @@ -299,7 +299,9 @@ function highlightSearchResults(searchResults, highlightedTokens) { // which would make the resulting HTML string invalid. // { and } are used for marking and tag (to avoid matches on single 'b' character) // < and > are used for marking and - highlightedTokens = highlightedTokens.map(token => token.replace('/[<\{\}]/g', '')); + 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);