autoEscape=false not working
hong1997 opened this issue · 3 comments
autoEscape: Escape characters in searchWords which are meaningful in regular expressions.
However, when input ‘***x’, the component crashes.
Auto escape escapes special characters like "." — but "***x" isn't a valid regexp. Still it shouldn't crash.
If you'd like to contribute a bug fix that would be nice!
I could try and take a look 😄
The problem seems to be in highlight-words-core
package. Essentially, it is trying to create a regex from ***x
but that fails. You can try it in the devTools console
new RegExp('***x')
returns
VM127:1 Uncaught SyntaxError: Invalid regular expression: /***x/: Nothing to repeat
at new RegExp ()
at :1:1
I am unsure how to proceed - applying autoEscape=true
escapes the special characters and it seems to fix the issue.
Should we log a warning and return an empty array, as "not matching"?