diff --git a/lib/search-query-parser.js b/lib/search-query-parser.js index f38ffe3..d1f2a4d 100644 --- a/lib/search-query-parser.js +++ b/lib/search-query-parser.js @@ -30,10 +30,11 @@ exports.parse = function (string, options) { // Get a list of search terms respecting single and double quotes var terms = string.match(/(\S+:'(?:[^'\\]|\\.)*')|(\S+:"(?:[^"\\]|\\.)*")|\S+|\S+:\S+/g); for (var i = 0; i < terms.length; i++) { - if(terms[i].indexOf(':') !== -1) { + var sepIndex = terms[i].indexOf(':'); + if(sepIndex !== -1) { var split = terms[i].split(':'), - key = split[0], - val = split[1]; + key = terms[i].slice(0, sepIndex), + val = terms[i].slice(sepIndex + 1); // Strip surrounding quotes val = val.replace(/^\"|\"$|^\'|\'$/g, ''); // Strip backslashes respecting escapes