You've already forked search-query-parser
Correctly handle semicolons within search term values
This commit is contained in:
@@ -30,10 +30,11 @@ exports.parse = function (string, options) {
|
|||||||
// Get a list of search terms respecting single and double quotes
|
// Get a list of search terms respecting single and double quotes
|
||||||
var terms = string.match(/(\S+:'(?:[^'\\]|\\.)*')|(\S+:"(?:[^"\\]|\\.)*")|\S+|\S+:\S+/g);
|
var terms = string.match(/(\S+:'(?:[^'\\]|\\.)*')|(\S+:"(?:[^"\\]|\\.)*")|\S+|\S+:\S+/g);
|
||||||
for (var i = 0; i < terms.length; i++) {
|
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(':'),
|
var split = terms[i].split(':'),
|
||||||
key = split[0],
|
key = terms[i].slice(0, sepIndex),
|
||||||
val = split[1];
|
val = terms[i].slice(sepIndex + 1);
|
||||||
// Strip surrounding quotes
|
// Strip surrounding quotes
|
||||||
val = val.replace(/^\"|\"$|^\'|\'$/g, '');
|
val = val.replace(/^\"|\"$|^\'|\'$/g, '');
|
||||||
// Strip backslashes respecting escapes
|
// Strip backslashes respecting escapes
|
||||||
|
|||||||
Reference in New Issue
Block a user