-
-
Notifications
You must be signed in to change notification settings - Fork 737
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 matchStringOrRegexp TypeError #998
Conversation
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.
Hi! Thanks for this.
lib/common.js
Outdated
@@ -320,7 +320,7 @@ function percentEncode(str) { | |||
} | |||
|
|||
function matchStringOrRegexp(target, pattern) { | |||
var str = !_.isUndefined(target) && target.toString ? target.toString() : target; | |||
var str = !_.isUndefined(target) ? (target.toString ? target.toString() : target) : ''; |
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.
It's a bit difficult to understand this double conditional expression. Would it be clearer as an if () ... else if () ... else
?
Hi, I have simplified the logic. I'm assuming |
Thanks! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you! |
Fixes
TypeError: Cannot read property 'match' of undefined
whenpattern
is a regex andtarget
is undefined.