Skip to content

Commit

Permalink
preventing errors from indexOf() on undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
bkimminich committed Nov 7, 2014
1 parent 891ff36 commit ddd457b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ exports.queryResultToJson = function(data, status) {
};

exports.startsWith = function(str, prefix) {
return str.indexOf(prefix) === 0;
return str ? str.indexOf(prefix) === 0 : false;
};

exports.endsWith = function(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
return str ? str.indexOf(suffix, str.length - suffix.length) !== -1 : false;
};

exports.contains = function(str, element) {
return str.indexOf(element) !== -1;
return str ? str.indexOf(element) !== -1 : false;
};

exports.unquote = function(str) {
Expand Down

0 comments on commit ddd457b

Please sign in to comment.