From d9ca5c9f23f898cc6cdd80cb2e6c80183907b136 Mon Sep 17 00:00:00 2001 From: Musiker15 Date: Sat, 20 Jun 2026 18:24:49 +0200 Subject: [PATCH] fix(web): remove redundant truthiness check (CodeQL js/trivial-conditional) In buildPreview's valueOf, null/undefined are already returned earlier, so the '&& value' in the object branch always evaluates to true. Drop it; the plain typeof + 'name' in value check is sufficient and still type-checks. --- apps/web/src/app/api/forms/[slug]/submit/route.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/web/src/app/api/forms/[slug]/submit/route.ts b/apps/web/src/app/api/forms/[slug]/submit/route.ts index 80297c8..de1fcc4 100644 --- a/apps/web/src/app/api/forms/[slug]/submit/route.ts +++ b/apps/web/src/app/api/forms/[slug]/submit/route.ts @@ -31,7 +31,8 @@ function buildPreview(spec: FormSpec, data: Record): string[] { if (value === undefined || value === null || value === "") return "—"; if (typeof value === "boolean") return value ? "Yes" : "No"; if (Array.isArray(value)) return value.map((v) => labelFor(field, String(v))).join(", "); - if (typeof value === "object" && value && "name" in value) { + // null/undefined already returned above, so a plain object check suffices. + if (typeof value === "object" && "name" in value) { return String((value as { name: unknown }).name); } if (field.options) return labelFor(field, String(value));