fix(matches): prevent regex state from breaking following validations#1975
fix(matches): prevent regex state from breaking following validations#1975profnandaa merged 1 commit intovalidatorjs:masterfrom
Conversation
| pattern = new RegExp(pattern, modifiers); | ||
| } | ||
| return pattern.test(str); | ||
| return !!str.match(pattern); |
There was a problem hiding this comment.
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.
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.
|
|
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 ! |
profnandaa
left a comment
There was a problem hiding this comment.
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