feat: message starter in the contact section
Build & Deploy / 🔍 Prepare (push) Successful in 5s
Build & Deploy / 🏗️ Build (push) Successful in 6m26s
Build & Deploy / 🚀 Deploy (push) Successful in 18s
Build & Deploy / 🩺 Smoke Test (push) Successful in 5s
Build & Deploy / 🔔 Notify (push) Successful in 2s

The visitor picks what they need and a prepared email types itself out; one
press opens it in their own mail app with subject and body filled in. The
mailto link is built by a tested pure function (src/domain/email.ts, spec
first) and only in the browser, so the address still never appears in the
page source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-04 09:01:03 +02:00
co-authored by Claude Opus 5.5
parent dc4a01cbe4
commit 390936856c
5 changed files with 318 additions and 10 deletions
+50 -1
View File
@@ -1,5 +1,10 @@
import { describe, expect, it } from "vitest";
import { assembleEmail, parseEmailParts, spellOutEmail } from "./email";
import {
assembleEmail,
mailtoHref,
parseEmailParts,
spellOutEmail,
} from "./email";
const parts = { user: "hello", domain: "mintel", tld: "me" } as const;
@@ -120,3 +125,47 @@ describe("spellOutEmail", () => {
).toBe("hello [at] mail [dot] site [dot] org");
});
});
describe("mailtoHref", () => {
it("opens a message to the address with subject and body", () => {
expect(mailtoHref(parts, { subject: "Hello", body: "Hi" })).toBe(
"mailto:hello@mintel.me?subject=Hello&body=Hi",
);
});
it("encodes spaces as %20, not as plus signs", () => {
expect(mailtoHref(parts, { subject: "A website", body: "Hi Marc" })).toBe(
"mailto:hello@mintel.me?subject=A%20website&body=Hi%20Marc",
);
});
it("encodes line breaks so the mail app keeps the paragraphs", () => {
expect(mailtoHref(parts, { subject: "S", body: "one\n\ntwo" })).toBe(
"mailto:hello@mintel.me?subject=S&body=one%0D%0A%0D%0Atwo",
);
});
it("encodes characters that would break the link", () => {
expect(mailtoHref(parts, { subject: "Q&A: 50%?", body: "a=b #1" })).toBe(
"mailto:hello@mintel.me?subject=Q%26A%3A%2050%25%3F&body=a%3Db%20%231",
);
});
it("keeps umlauts readable for the mail app", () => {
expect(mailtoHref(parts, { subject: "Grüße", body: "ä" })).toBe(
"mailto:hello@mintel.me?subject=Gr%C3%BC%C3%9Fe&body=%C3%A4",
);
});
it("leaves out an empty subject or body instead of sending empty fields", () => {
expect(mailtoHref(parts, { subject: "", body: "" })).toBe(
"mailto:hello@mintel.me",
);
expect(mailtoHref(parts, { subject: "Only subject", body: "" })).toBe(
"mailto:hello@mintel.me?subject=Only%20subject",
);
expect(mailtoHref(parts, { subject: "", body: "Only body" })).toBe(
"mailto:hello@mintel.me?body=Only%20body",
);
});
});