mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 18:04:31 -04:00
Fix for regex issue with product autocomplete
This commit is contained in:
parent
7317bfc8c9
commit
12c185ca49
@ -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…
x
Reference in New Issue
Block a user