refactor(deb): classify dependency architecture polarity once (#16871)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-05 08:07:35 +08:00
1 parent e7d9d17ef5
commit 554c752d38
1 file changed
+6 -11
+6 -11
View File
@@ -366,19 +366,14 @@ export const parseDebianDependency = (
countWhitespaceTokens(inner, maxArchitectureItems) > maxArchitectureItems
)
return null;
const tokens = inner
.trim()
.split(/\s+/u)
.filter((token) => token.length > 0);
if (tokens.length === 0) return null;
const negated = tokens.every((token) => token.startsWith("!"));
const mixed = tokens.some((token) => token.startsWith("!")) !== negated;
if (mixed) return null;
const text = inner.trim();
if (text === "") return null;
const tokens = text.split(/\s+/u);
const negated = text.startsWith("!");
if (tokens.some((token) => token.startsWith("!") !== negated)) return null;
arch_restriction = {
negated,
architectures: tokens.map((token) =>
token.startsWith("!") ? token.slice(1) : token,
),
architectures: negated ? tokens.map((token) => token.slice(1)) : tokens,
};
rest = rest.slice(close + 1).trim();
}