File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
packages/core/src/ui/utils Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ export const wordListSearch = (
18
18
if ( ! searchWord || ! wordList ?. length ) return suggestionList ;
19
19
20
20
const parsedSearchWord = isCaseSensitive ? searchWord : searchWord . toLowerCase ( ) ;
21
+ let parsedSearchWordRegExp ;
22
+ try {
23
+ parsedSearchWordRegExp = new RegExp ( `^${ parsedSearchWord } .*$` ) ;
24
+ } catch {
25
+ return suggestionList ;
26
+ }
21
27
22
28
while ( continueSearching ) {
23
29
const currentWord = wordList [ currentWordIdx ] ;
@@ -36,10 +42,9 @@ export const wordListSearch = (
36
42
}
37
43
38
44
for ( let idx = 0 ; idx < suggestionListLength ; idx ++ ) {
39
- const startWith = new RegExp ( `^${ parsedSearchWord } .*$` ) ;
40
45
const currentWord = wordList [ currentWordIdx + idx ] ;
41
46
42
- if ( startWith . test ( currentWord ) ) {
47
+ if ( parsedSearchWordRegExp . test ( currentWord ) ) {
43
48
suggestionList . push ( currentWord ) ;
44
49
}
45
50
}
You can’t perform that action at this time.
0 commit comments