Skip to content

Commit

Permalink
Condense the if blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed Feb 20, 2016
1 parent 1bd5b1f commit ebcca98
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -839,15 +839,9 @@
return false;
}
var firstPaddingChar = str.indexOf('=');
if (firstPaddingChar >= 0) {
if (len - firstPaddingChar > 2) {
return false;
}
if (firstPaddingChar < len - 1 && str[len - 1] !== '=') {
return false;
}
}
return true;
return firstPaddingChar === -1 ||
firstPaddingChar === len - 1 ||
(firstPaddingChar === len - 2 && str[len - 1] === '=');
};

validator.isMongoId = function (str) {
Expand Down

0 comments on commit ebcca98

Please sign in to comment.