react-highlight-words
react-highlight-words copied to clipboard
autoEscape not working when one of the searchWords is regex
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
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.
Suggestion: Check instanceof RegExp for each searchWords value in the autoescape function and don't escape if it is RegExp.