diff --git a/lib/imap.js b/lib/imap.js index ac64036..c877e79 100644 --- a/lib/imap.js +++ b/lib/imap.js @@ -814,12 +814,11 @@ ImapConnection.prototype._sort = function(which, sorts, options, cb) { + 'Expected string. Got: ' + typeof criteria); var modifier = ''; - if (criterion.charAt(0) === '!') { + if (criterion[0] === '-') { modifier = 'REVERSE '; criterion = criterion.substring(1); } - criterion = criterion.toUpperCase(); - switch (criterion) { + switch (criterion.toUpperCase()) { case 'ARRIVAL': case 'CC': case 'DATE':