diff --git a/src/app/contact/contact-form.tsx b/src/app/contact/contact-form.tsx index 3abfea8..859f612 100644 --- a/src/app/contact/contact-form.tsx +++ b/src/app/contact/contact-form.tsx @@ -15,8 +15,13 @@ const fieldClasses = * looks like it worked and silently loses the enquiry. Replacing this with a * route handler or a form service is tracked in issue #2 — when that lands, * the mailto fallback should stay for anyone with JavaScript disabled. + * + * `about` is the practitioner a directory enquiry concerns. Enquiries route + * through Bluehex rather than to the practitioner directly — no address is + * ever published on a profile — so this only has to say who was meant, and the + * mail still comes here. */ -export function ContactForm({ email }: { email: string }) { +export function ContactForm({ email, about }: { email: string; about?: string }) { const onSubmit = (event: React.FormEvent) => { event.preventDefault(); @@ -27,20 +32,39 @@ export function ContactForm({ email }: { email: string }) { `Name: ${value("name")}`, `Email: ${value("email")}`, `Phone: ${value("phone")}`, + ...(about ? [`About: ${about}`] : []), "", value("message"), ].join("\n"); const query = new URLSearchParams({ - subject: `Enquiry from ${value("name") || "the website"}`, + subject: about + ? `Enquiry about ${about}, from ${value("name") || "the website"}` + : `Enquiry from ${value("name") || "the website"}`, body, }); - window.location.href = `mailto:${email}?${query}`; + /* `URLSearchParams.toString()` serialises as `application/x-www-form- + urlencoded`, which writes a space as `+`. A mailto query is not form + encoded — RFC 6068 wants percent-encoding, where `+` is a literal plus — + so clients split on it and the strict ones open a compose window reading + "Enquiry+about+Mara+Ellison". A literal plus in a field is already + `%2B` by this point, so replacing every remaining `+` is safe. + + `URLSearchParams` is still what builds the query: it percent-encodes `&`, + `?`, CR and LF, so no field value can inject a second mailto header. */ + window.location.href = `mailto:${email}?${query.toString().replace(/\+/g, "%20")}`; }; return (
+ {about ? ( +

+ Enquiring about {about}. + Bluehex passes it on — practitioners are not contacted directly. +

+ ) : null} +