Adv item search: actually make string comparisons case-insensitive

This commit is contained in:
phantamanta44 2021-03-22 12:15:50 -05:00
parent 886d720efe
commit 17af7f8d3f

View file

@ -344,16 +344,25 @@ class EqualityTerm extends BinaryOpTerm {
constructor(left, right) {
super('boolean', 'any', left, 'any', right);
}
apply(a, b) {
return (typeof a === 'string' && typeof b === 'string')
? this.compare(a.toLowerCase(), b.toLowerCase()) : this.compare(a, b);
}
compare(a, b) {
throw new Error('Abstract method!');
}
}
class EqTerm extends EqualityTerm {
apply(a, b) {
compare(a, b) {
return a === b;
}
}
class NeqTerm extends EqualityTerm {
apply(a, b) {
compare(a, b) {
return a !== b;
}
}
@ -376,7 +385,8 @@ class InequalityTerm extends BinaryOpTerm {
apply(a, b) {
checkComparable(a);
checkComparable(b);
return this.compare(a, b);
return (typeof a === 'string' && typeof b === 'string')
? this.compare(a.toLowerCase(), b.toLowerCase()) : this.compare(a, b);
}
compare(a, b) {
@ -434,7 +444,7 @@ class MulTerm extends ArithmeticTerm {
class DivTerm extends ArithmeticTerm {
apply(a, b) {
return a / b;
return a / b;
}
}