forked from e621ng/e621ng
[Blacklist] Add fuzzy direct equality to filesize blacklist tag (#784)
The search metatag `filesize`, when using a direct equality comparison (`=`, e.g. `filesize:10kb`), instead uses a range comparison (`..`) with the bounds being the value + & - 5% (e.g. `filesize:10kb` is equal to `filesize:9.5kb..10.5kb`). The equivalent blacklist tag mirrored the search metatag in all aspects but this; this commit adds this fuzzy matching capability.
This commit is contained in:
parent
9a9f175da4
commit
c137f17f9c
@ -170,7 +170,19 @@ class FilterToken {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else this.value = FilterUtils.normalizeData(raw, this.type);
|
} else {
|
||||||
|
this.value = FilterUtils.normalizeData(raw, this.type);
|
||||||
|
if (this.comparison === "=" && this.type === "filesize") {
|
||||||
|
// If the comparison uses direct equality, mirror the fudging behavior of
|
||||||
|
// the filesize search metatag by changing the comparison to a range of
|
||||||
|
// the initial value -5% and +5%.
|
||||||
|
this.comparison = "..";
|
||||||
|
this.value = [
|
||||||
|
Math.trunc(this.value * 0.95),
|
||||||
|
Math.trunc(this.value * 1.05),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user