-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does addEntry work with toString? #23
Comments
This looks like the quotes are preserved in the first example to me? var SearchString = require("search-string")
const str1 = "";
const searchString1 = SearchString.parse(str1);
searchString1.addEntry('from', '\'"\'"', false);
console.log(searchString1.getConditionArray()[0].value) // '\"'\"
const val = searchString1.getConditionArray()[0].value;
console.log(val.length) // 4. Let me know if this isn't what you expected? The first string is preserved. |
@ttacon Oh sorry for the confusion, the strings are not separate, I only have issue on ...
searchString1.addEntry('from', '\'"\'"', false); // a length 4 string
...
console.log(searchString2.getConditionArray()[0].value) // \"\"
console.log(searchString2.getConditionArray()[0].value.length) // 2 Edit: I would expect the length of |
Ah, my apologies for not clearly reading the second example 😅. I believe that this is currently functioning as intended (treating the initial nested |
I'm trying to follow
Would you mind walking me another example? let searchString = SearchString.parse(`to:a"b'"c'`); // 7 characters, 2 single quotes, 1 in between, 1 at last
console.log(searchString.getConditionArray()[0].value); // ab'c Ultimately I wish to see Speaking of use-cases, I plan to use the search keywords to perform character-by-character exact match searching, so if a document actually contains quote pairs, I might not be able to find it when my query string include those quotes. That being said, I could just avoid typing the whole sentence, but the inner phrase instead to workaround this. |
When trying the mentioned functions with quotes, I am confused where I thought the mixed quotes would be preserved after parsing the stringified query. Is the following behavior intended? or I simply misused the functions?
The text was updated successfully, but these errors were encountered: