mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Fixes select2 bug from RegEx escaped values
Escaped values are needed for tablesorter filter, but unescaped values should be used in other contexts. (e.g., "a or b", "a/b")
This commit is contained in:
parent
9475a7c39c
commit
db5a0d5419
@ -65,17 +65,18 @@
|
|||||||
v = v.join('\u0000');
|
v = v.join('\u0000');
|
||||||
}
|
}
|
||||||
// escape special regex characters (http://stackoverflow.com/a/9310752/145346)
|
// escape special regex characters (http://stackoverflow.com/a/9310752/145346)
|
||||||
v = v.replace(/[-[\]{}()*+?.,/\\^$|#]/g, '\\$&');
|
var v_escape = v.replace(/[-[\]{}()*+?.,/\\^$|#]/g, '\\$&');
|
||||||
// convert string back into an array
|
// convert string back into an array
|
||||||
if (arry) {
|
if (arry) {
|
||||||
v = v.split('\u0000');
|
v = v.split('\u0000');
|
||||||
|
v_escape = v_escape.split('\u0000');
|
||||||
}
|
}
|
||||||
if (!ts.isEmptyObject($cell.find('.select2').data())) {
|
if (!ts.isEmptyObject($cell.find('.select2').data())) {
|
||||||
$input
|
$input
|
||||||
// add regex, so we filter exact numbers
|
// add regex, so we filter exact numbers
|
||||||
.val(
|
.val(
|
||||||
$.isArray(v) && v.length && v.join('') !== '' ?
|
$.isArray(v_escape) && v_escape.length && v_escape.join('') !== '' ?
|
||||||
'/(' + matchPrefix + (v || []).join(matchSuffix + '|' + matchPrefix) + matchSuffix + ')/' + flags :
|
'/(' + matchPrefix + (v_escape || []).join(matchSuffix + '|' + matchPrefix) + matchSuffix + ')/' + flags :
|
||||||
''
|
''
|
||||||
)
|
)
|
||||||
.trigger('search');
|
.trigger('search');
|
||||||
|
Loading…
Reference in New Issue
Block a user