Add honeypot, spam protection to contact form

This commit is contained in:
2026-05-02 11:24:11 +12:00
parent cd8d581f7a
commit 3587ba7f26
25 changed files with 553 additions and 41 deletions
+1 -1
View File
@@ -34,7 +34,7 @@
<div class="error-actions">
<a href="/" class="btn btn-yellow">Take me home</a>
<a href="/booking" class="btn btn-outline">Book a Meet &amp; Greet</a>
<a href="/contact-us" class="btn btn-outline">Book a Meet &amp; Greet</a>
</div>
</div>
</main>
+4
View File
@@ -7,6 +7,10 @@ export async function load({ params }) {
throw redirect(301, '/about');
}
if (params.slug === 'booking') {
throw redirect(301, '/contact-us');
}
const slug = params.slug as StaticPageSlug;
const page = staticPages[slug];
+1 -1
View File
@@ -184,7 +184,7 @@
<LegalPage pageContent={termsAndConditionsContent} />
{:else if data.slug === 'privacy-policy'}
<LegalPage pageContent={privacyPolicyContent} />
{:else if data.slug === 'booking'}
{:else if data.slug === 'contact-us'}
<BookingPage booking={data.content.booking} />
{:else}
<main class="static-page">
@@ -24,6 +24,13 @@ describe('static slug page server load', () => {
});
});
it('redirects the legacy booking slug to /contact-us', async () => {
await expect(load({ params: { slug: 'booking' } } as never)).rejects.toMatchObject({
status: 301,
location: '/contact-us'
});
});
it('throws a 404 for unknown slugs', async () => {
await expect(load({ params: { slug: 'missing-page' } } as never)).rejects.toMatchObject({
status: 404
+1 -1
View File
@@ -10,7 +10,7 @@ describe('static slug route page', () => {
['puppy-visits', 'Introducing Puppy Visits: Building strong foundations for our pack walks!'],
['our-pricing', 'Simple, transparent pricing — no lock-in contracts.'],
['about', 'Who we are'],
['booking', "Fill in the form below and we'll be in touch to arrange a free introduction."],
['contact-us', "Fill in the form below and we'll be in touch to arrange a free introduction."],
['terms-and-conditions', '1. Application of Terms'],
['privacy-policy', 'How we collect your information']
] as const)('renders the %s page branch', (slug, expectedText) => {
+1 -1
View File
@@ -29,7 +29,7 @@ describe('root layout navigation behavior', () => {
navigateHandler({
from: { url: new URL('https://www.goodwalk.co.nz/about') },
to: { url: new URL('https://www.goodwalk.co.nz/booking') }
to: { url: new URL('https://www.goodwalk.co.nz/contact-us') }
});
expect(disableScrollHandling).toHaveBeenCalledTimes(1);
+1 -1
View File
@@ -8,7 +8,7 @@ const routes = [
'/puppy-visits',
'/our-pricing',
'/about',
'/booking',
'/contact-us',
'/terms-and-conditions',
'/privacy-policy'
];
+1
View File
@@ -15,6 +15,7 @@ describe('sitemap endpoint', () => {
expect(response.headers.get('content-type')).toBe('application/xml; charset=utf-8');
expect(body).toContain('<loc>https://www.goodwalk.co.nz/</loc>');
expect(body).toContain('<loc>https://www.goodwalk.co.nz/contact-us</loc>');
expect(body).toContain('<loc>https://www.goodwalk.co.nz/privacy-policy</loc>');
expect(body).toContain('<lastmod>2026-05-01</lastmod>');
expect(body.match(/<url>/g)).toHaveLength(9);