Make *Filter.matches case insensitive for attrs
This commit is contained in:
parent
57fecb06d5
commit
9c78c06643
|
@ -50,12 +50,13 @@ ApproximateFilter.prototype.matches = function (target) {
|
||||||
throw new TypeError('target (object) required');
|
throw new TypeError('target (object) required');
|
||||||
|
|
||||||
var matches = false;
|
var matches = false;
|
||||||
if (target.hasOwnProperty(this.attribute)) {
|
var tv = Filter.get_attr_caseless(target, this.attribute);
|
||||||
var tv = target[this.attribute];
|
|
||||||
|
if (tv !== null) {
|
||||||
if (Array.isArray(tv)) {
|
if (Array.isArray(tv)) {
|
||||||
matches = (tv.indexOf(this.value) != -1);
|
matches = (tv.indexOf(this.value) != -1);
|
||||||
} else {
|
} else {
|
||||||
matches = (this.value === target[this.attribute]);
|
matches = (this.value === tv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,9 @@ EqualityFilter.prototype.matches = function (target) {
|
||||||
throw new TypeError('target (object) required');
|
throw new TypeError('target (object) required');
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
var tv = Filter.get_attr_caseless(target, this.attribute);
|
||||||
|
|
||||||
if (target.hasOwnProperty(this.attribute)) {
|
if (tv !== null) {
|
||||||
var value = this.value;
|
var value = this.value;
|
||||||
return Filter.multi_test(
|
return Filter.multi_test(
|
||||||
function (v) {
|
function (v) {
|
||||||
|
@ -59,7 +60,7 @@ EqualityFilter.prototype.matches = function (target) {
|
||||||
v = v.toLowerCase();
|
v = v.toLowerCase();
|
||||||
return value === v;
|
return value === v;
|
||||||
},
|
},
|
||||||
target[this.attribute]);
|
tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -94,7 +94,9 @@ ExtensibleFilter.prototype.matches = function (target) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
if (this.matchType && target.hasOwnProperty(this.matchType)) {
|
var tv = Filter.get_attr_caseless(target, this.matchType);
|
||||||
|
|
||||||
|
if (this.matchType && tv !== null) {
|
||||||
|
|
||||||
if (self.rule === '2.5.13.4' || self.rule === 'caseIgnoreSubstringsMatch') {
|
if (self.rule === '2.5.13.4' || self.rule === 'caseIgnoreSubstringsMatch') {
|
||||||
var f = {
|
var f = {
|
||||||
|
@ -120,7 +122,7 @@ ExtensibleFilter.prototype.matches = function (target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.value === v;
|
return self.value === v;
|
||||||
}, target[this.matchType]);
|
}, tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -50,11 +50,13 @@ GreaterThanEqualsFilter.prototype.matches = function (target) {
|
||||||
if (typeof (target) !== 'object')
|
if (typeof (target) !== 'object')
|
||||||
throw new TypeError('target (object) required');
|
throw new TypeError('target (object) required');
|
||||||
|
|
||||||
if (target.hasOwnProperty(this.attribute)) {
|
var tv = Filter.get_attr_caseless(target, this.attribute);
|
||||||
|
|
||||||
|
if (tv !== null) {
|
||||||
var value = this.value;
|
var value = this.value;
|
||||||
return Filter.multi_test(
|
return Filter.multi_test(
|
||||||
function (v) { return value <= v; },
|
function (v) { return value <= v; },
|
||||||
target[this.attribute]);
|
tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -50,11 +50,13 @@ LessThanEqualsFilter.prototype.matches = function (target) {
|
||||||
if (typeof (target) !== 'object')
|
if (typeof (target) !== 'object')
|
||||||
throw new TypeError('target (object) required');
|
throw new TypeError('target (object) required');
|
||||||
|
|
||||||
if (target.hasOwnProperty(this.attribute)) {
|
var tv = Filter.get_attr_caseless(target, this.attribute);
|
||||||
|
|
||||||
|
if (tv !== null) {
|
||||||
var value = this.value;
|
var value = this.value;
|
||||||
return Filter.multi_test(
|
return Filter.multi_test(
|
||||||
function (v) { return value >= v; },
|
function (v) { return value >= v; },
|
||||||
target[this.attribute]);
|
tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -44,7 +44,7 @@ PresenceFilter.prototype.matches = function (target) {
|
||||||
if (typeof (target) !== 'object')
|
if (typeof (target) !== 'object')
|
||||||
throw new TypeError('target (object) required');
|
throw new TypeError('target (object) required');
|
||||||
|
|
||||||
return target.hasOwnProperty(this.attribute);
|
return (Filter.get_attr_caseless(target, this.attribute) !== null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,9 @@ SubstringFilter.prototype.matches = function (target) {
|
||||||
if (typeof (target) !== 'object')
|
if (typeof (target) !== 'object')
|
||||||
throw new TypeError('target (object) required');
|
throw new TypeError('target (object) required');
|
||||||
|
|
||||||
if (target.hasOwnProperty(this.attribute)) {
|
var tv = Filter.get_attr_caseless(target, this.attribute);
|
||||||
|
|
||||||
|
if (tv !== null) {
|
||||||
var re = '';
|
var re = '';
|
||||||
if (this.initial)
|
if (this.initial)
|
||||||
re += '^' + escapeRegExp(this.initial) + '.*';
|
re += '^' + escapeRegExp(this.initial) + '.*';
|
||||||
|
@ -95,7 +97,7 @@ SubstringFilter.prototype.matches = function (target) {
|
||||||
v = v.toLowerCase();
|
v = v.toLowerCase();
|
||||||
return matcher.test(v);
|
return matcher.test(v);
|
||||||
},
|
},
|
||||||
target[this.attribute]);
|
tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue