Open nstephens opened 6 years ago
I just got the same problem. I resolved it by using the option "method" of the object "match" like so :
options : {
match : {
enabled : true,
method : function(element, phrase) {
return element.indexOf(phrase) !== -1;
}
}
}
by searching the source code, I found the default method is equivalent to : function(element, phrase) { return element.search(phrase) !== -1; }
and String.prototype.search
convert "phrase"
to a Regex.
this is not what a end user would expect.
I have a lot of data that I search that has strings with parentheses, eg:
[ {"tag": "CA005", "name": "Los Angeles (California)"}, {"tag": "CA003", "name": "San Diego (California)"}, {"tag": "WA002", "name": "Seattle (Washington)"}, ]
The script will detect and find the name well, but if I begin to include the parentheses (or backspace to try to select a new location), the script will error in console with a RegEx error about the unterminated group.
Is there any way we could automatically apply a filter to sanitize the input phrase first and escape characters like Parentheses? I'd be happy to try to help if you can suggest which function I should try working with. I'm guessing it's likely the function match() or function findMatch(), but I haven't looked too closely.
Awesome work overall, thank you so much for such a great resource!