Skip to content

Commit

Permalink
Bug #827 Defensive coding around target
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwsperber committed Feb 13, 2017
1 parent 0fb8c3d commit f2ae8c1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,9 @@ function percentEncode(str) {
}

function matchStringOrRegexp(target, pattern) {
if (pattern instanceof RegExp) {
return target.toString().match(pattern);
} else {
return target.toString() === pattern;
}
var str = target && target.toString ? target.toString() : target;

return pattern instanceof RegExp ? str.match(pattern) : str === pattern;
}

// return [newKey, newValue]
Expand Down

0 comments on commit f2ae8c1

Please sign in to comment.