File tree Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -91,18 +91,13 @@ export default {
9191
9292 const highlightText = (text ) => {
9393 const query = filters? .searchQuery && isNaN (Number (filters .searchQuery )) ? filters .searchQuery .trim ().toLowerCase () : undefined ;
94- if (! query) return text;
9594
96- const indexOfQuery = String (text).toLowerCase ().indexOf (query);
97- if (indexOfQuery === - 1 ) return text;
98-
99- const originalText = String (text)
100- const prefix = originalText .slice (0 , indexOfQuery);
101- const matchPart = originalText .slice (indexOfQuery, indexOfQuery + query .length );
102- const suffix = originalText .slice (indexOfQuery + query .length );
103- return ` ${ prefix} <mark class="border">${ matchPart} </mark>${ suffix} ` ;
95+ if (! query) return text;
96+ const regex = new RegExp (` (${ query} )` , ' gi' );
97+ return String (text).replace (regex, ' <mark>$1</mark>' );
10498
10599 }
100+
106101 return {
107102 comments: filteredComments,
108103 commentsIsLoading,
You can’t perform that action at this time.
0 commit comments