-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
fix(matches): prevent regex state from breaking following validations #1975
Conversation
return pattern.test(str); | ||
return !!str.match(pattern); |
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.
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.
What about using Array.isArray(str.match(pattern))
or str.match(pattern) !== null
since the possible return values of .matches
are Array or null?
The result is obviously the same, but semantically seems more appropriate to me :)
And maybe they'll be more inclined to accept the PR :)
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 honestly find that excessively verbose and probably won't be a blocker for the pr. Let's see what the maintainers think.
Codecov Report
@@ Coverage Diff @@
## master #1975 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 103 103
Lines 2097 2097
Branches 473 473
=========================================
Hits 2097 2097
Continue to review full report at Codecov.
|
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.
Thank you @fedeci ! LGTM 🎉
We have published an hot fix in express-validator so we are fine to have this merged later too! |
Good for you, really sorry for the delay @fedeci ! |
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 catch, thanks @fedeci !
@profnandaa Actually, I catched it! 😂😂😂 |
Ah, thanks @tonysamperi :-D |
Refs
express-validator/express-validator#1127
express-validator/express-validator#1150
Checklist