From df1851b27de2821d7faa7150ca2bdd1503f05fd3 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 8 May 2026 22:59:57 +0100 Subject: [PATCH] test: simplify export html specificity count --- .../reply/export-html/template.security.test.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/auto-reply/reply/export-html/template.security.test.ts b/src/auto-reply/reply/export-html/template.security.test.ts index 2be2f256c78..ec6b3cc123f 100644 --- a/src/auto-reply/reply/export-html/template.security.test.ts +++ b/src/auto-reply/reply/export-html/template.security.test.ts @@ -145,9 +145,12 @@ function selectorSpecificity(selector: string): [number, number, number] { const ids = selector.match(/#[\w-]+/g)?.length ?? 0; const classes = selector.match(/\.[\w-]+/g)?.length ?? 0; const withoutIdsOrClasses = selector.replace(/#[\w-]+|\.[\w-]+/g, " "); - const elements = withoutIdsOrClasses - .split(/[\s>+~]+/) - .filter((part) => /^[a-z][\w-]*$/i.test(part)).length; + let elements = 0; + for (const part of withoutIdsOrClasses.split(/[\s>+~]+/)) { + if (/^[a-z][\w-]*$/i.test(part)) { + elements++; + } + } return [ids, classes, elements]; }