Fix for regex issue with product autocomplete
This commit is contained in:
parent
7317bfc8c9
commit
12c185ca49
2 changed files with 9 additions and 2 deletions
|
|
@ -30991,7 +30991,7 @@ function searchData(data, key, fuzzy) {
|
|||
matches = fuse.search(q);
|
||||
} else {
|
||||
matches = [];
|
||||
substrRegex = new RegExp(q, 'i');
|
||||
substrRegex = new RegExp(escapeRegExp(q), 'i');
|
||||
$.each(data, function(i, obj) {
|
||||
if (substrRegex.test(obj[key])) {
|
||||
matches.push(obj);
|
||||
|
|
@ -31002,6 +31002,9 @@ function searchData(data, key, fuzzy) {
|
|||
}
|
||||
};
|
||||
|
||||
function escapeRegExp(str) {
|
||||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||
}
|
||||
var NINJA = NINJA || {};
|
||||
|
||||
NINJA.TEMPLATES = {
|
||||
|
|
|
|||
|
|
@ -1097,7 +1097,7 @@ function searchData(data, key, fuzzy) {
|
|||
matches = fuse.search(q);
|
||||
} else {
|
||||
matches = [];
|
||||
substrRegex = new RegExp(q, 'i');
|
||||
substrRegex = new RegExp(escapeRegExp(q), 'i');
|
||||
$.each(data, function(i, obj) {
|
||||
if (substrRegex.test(obj[key])) {
|
||||
matches.push(obj);
|
||||
|
|
@ -1107,3 +1107,7 @@ function searchData(data, key, fuzzy) {
|
|||
cb(matches);
|
||||
}
|
||||
};
|
||||
|
||||
function escapeRegExp(str) {
|
||||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue