mirror of https://github.com/zulip/zulip.git
search: Parse quoted strings as single tokens
(imported from commit 252f2657881ad4184a2564d16bf11558613efead)
This commit is contained in:
parent
4bfda4c49e
commit
60e479bdf1
|
@ -290,19 +290,19 @@ exports.set_compose_defaults = function (opts) {
|
|||
exports.parse = function (str) {
|
||||
var operators = [];
|
||||
var search_term = [];
|
||||
$.each(str.split(/ +/), function (idx, token) {
|
||||
$.each(str.match(/"[^"]+"|\S+/g), function (idx, token) {
|
||||
var parts, operator;
|
||||
if (token.length === 0)
|
||||
return;
|
||||
parts = token.split(':');
|
||||
if (parts.length > 1) {
|
||||
if (token[0] === '"' || parts.length === 1) {
|
||||
// Looks like a normal search term.
|
||||
search_term.push(token);
|
||||
} else {
|
||||
// Looks like an operator.
|
||||
// FIXME: Should we skip unknown operator names here?
|
||||
operator = parts.shift();
|
||||
operators.push([operator, decodeOperand(parts.join(':'))]);
|
||||
} else {
|
||||
// Looks like a normal search term.
|
||||
search_term.push(token);
|
||||
}
|
||||
});
|
||||
// NB: Callers of 'parse' can assume that the 'search' operator is last.
|
||||
|
|
Loading…
Reference in New Issue