Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoEscape not working when one of the searchWords is regex #64

Open
mkurek opened this issue Sep 24, 2018 · 2 comments
Open

autoEscape not working when one of the searchWords is regex #64

mkurek opened this issue Sep 24, 2018 · 2 comments

Comments

@mkurek
Copy link

mkurek commented Sep 24, 2018

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
Copy link
Owner

bvaughn commented Sep 24, 2018

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
Copy link

Suggestion: Check instanceof RegExp for each searchWords value in the autoescape function and don't escape if it is RegExp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants