Closed bradvogel closed 7 years ago
I think the current output is the most expected. The comma is an item delimiter.
To make it work the way you want we could escape the comma (either programmatically or by telling the user):
require('search-query-parser').parse('test from:"one\,two"', {keywords: ['from']})
It seems clearer to me that anything inside of quotes is automatically escaped (except other quotes of course). So double quotes always have precedence.
So the following would the true:
from:one,two
-> from: ["one", "two"]
from:one\,two
-> from: ["one,two"]
from:"one,two"
-> from: ["one,two"]
from:"one\,two"
-> from: ["one,two"]
That works too. We can use the quotes to mean "one item" and the comma as a separator. We'd need exhaustive test coverage for this though. Let's follow up on the PR.
And thanks for the PR 👍
fyi, we just released https://github.com/mixmaxhq/search-string that fixes this
The example:
require('search-query-parser').parse('test from:"one,two"',{keywords: ['from']})
returns two values, egfrom: [ 'one', 'two' ],
I'd think
"one,two"
should be treated as one word, so it should returnfrom: [ 'one,two' ],