-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Escape regex tokens within field names #38
Conversation
Codecov Report
@@ Coverage Diff @@
## master #38 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 14 15 +1
Lines 157 159 +2
Branches 34 34
=====================================
+ Hits 157 159 +2
Continue to review full report at Codecov.
|
src/utils.js
Outdated
@@ -0,0 +1,3 @@ | |||
// @flow | |||
export const escapeRegexTokens = (str: string): string => | |||
str.replace(/([.\-[])/g, '\\$1') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've found this robust regex on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping - maybe use this one with a comment where is it taken from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I'll change that.
This solution works for me too and I've suggested even more complex regex to improve this fix. |
Published in |
Thanks @erikras ! |
Resolves #37
@erikras I just copied the suitable test-case and adjusted it to demonstrate the issue. Let me know if I should structure the tests differently. 👍