autoEscape not working when one of the searchWords is regex
mkurek opened this issue · 2 comments
mkurek commented
When autoEscape
is set to true and (at least) one of the elements in searchWords
array is regex, the following exception is raised:
TypeError
str.replace is not a function
Example: https://codesandbox.io/s/20p3zk380n
bvaughn commented
The autoEscape
parameter is meant to escape sensitive characters before converting a string to a regex. It's not meant to work with regexes.
I guess this is a bug, but I don't plan on fixing it. I'd be happy to review a PR though.
warmbowski commented
Suggestion: Check instanceof RegExp
for each searchWords
value in the autoescape function and don't escape if it is RegExp.