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