Fix: fix tests

This commit is contained in:
Pieter Vander Vennet 2025-09-01 00:58:11 +02:00
parent 34cc65b240
commit 42f07bc1f3

View file

@ -1006,15 +1006,18 @@ export class TagUtils {
* Returns a similarly structured tag, but all tags with an empty value are removed. * Returns a similarly structured tag, but all tags with an empty value are removed.
* Those are assumed to be all met (and thus true) * Those are assumed to be all met (and thus true)
* *
* new And([new Tag("a", "b"), new Tag("c", "")] // => new Tag("a","b") * TagUtils.removeEmptyParts(new And([new Tag("a", "b"), new Tag("c", "")])) // => new Tag("a","b")
* new And([new Tag("c", "")] // => true * TagUtils.removeEmptyParts(new And([new Tag("c", "")])) // => true
*/ */
public static removeEmptyParts(tag: UploadableTag): UploadableTag | true { public static removeEmptyParts(tag: UploadableTag): UploadableTag | true {
if (tag["and"]) { if (tag["and"]) {
const tags = <UploadableTag[]>tag["and"] const tags = <UploadableTag[]>tag["and"]
const cleaned = tags.map(t => TagUtils.removeEmptyParts(t)) const cleaned = tags.map(t => TagUtils.removeEmptyParts(t))
const filtered = <UploadableTag[]>cleaned.filter(t => t !== true) const filtered = <UploadableTag[]>cleaned.filter(t => t !== true)
return new And(filtered) if (filtered.length === 0) {
return true
}
return <true | UploadableTag>new And(filtered).optimize()
} }
if (tag.isNegative()) { if (tag.isNegative()) {
return true return true