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 {
91
91
92
92
const highlightText = (text ) => {
93
93
const query = filters? .searchQuery && isNaN (Number (filters .searchQuery )) ? filters .searchQuery .trim ().toLowerCase () : undefined ;
94
- if (! query) return text;
95
94
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>' );
104
98
105
99
}
100
+
106
101
return {
107
102
comments: filteredComments,
108
103
commentsIsLoading,
You can’t perform that action at this time.
0 commit comments