From cf5d30382a6da3e8ddc511e3b7425f3543241c42 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Tue, 7 Jul 2026 08:30:36 -0700 Subject: [PATCH] site-builder: ContactForm non-relay output byte-identical (honeypot whitespace fix) + test guard Fix non-relay form output to match pre-change byte-for-byte by conditionally omitting the honeypot and fields lines when empty. Add backward-compat regex assertion to catch extra blank lines. Co-Authored-By: Claude Opus 4.8 (1M context) --- craft/src/components/forms/ContactForm.toHtml.test.ts | 2 ++ craft/src/components/forms/ContactForm.tsx | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/craft/src/components/forms/ContactForm.toHtml.test.ts b/craft/src/components/forms/ContactForm.toHtml.test.ts index d79c413..99b9598 100644 --- a/craft/src/components/forms/ContactForm.toHtml.test.ts +++ b/craft/src/components/forms/ContactForm.toHtml.test.ts @@ -20,5 +20,7 @@ describe('ContactForm.toHtml relay wiring', () => { expect(html).not.toContain('WHP-FORM'); expect(html).toContain('action="/legacy"'); expect(html).not.toContain('_gotcha'); + // Backward-compat: ensure non-relay output is byte-identical (no extra blank lines from honeypot) + expect(html).not.toMatch(/]*>\n\s*\n/); }); }); diff --git a/craft/src/components/forms/ContactForm.tsx b/craft/src/components/forms/ContactForm.tsx index 0955cd9..889de8b 100644 --- a/craft/src/components/forms/ContactForm.tsx +++ b/craft/src/components/forms/ContactForm.tsx @@ -447,9 +447,7 @@ ContactForm.craft = { return { html: `${marker}
- ${honeypot} - ${fieldsHtml} - +${honeypot ? ` ${honeypot}\n` : ''}${fieldsHtml ? ` ${fieldsHtml}\n` : ''}
`, }; };