[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:
jmortiger 2024-11-10 23:23:56 -05:00 committed by GitHub
parent 9a9f175da4
commit c137f17f9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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),
];
}
}
} }
/** /**