From ef638115b8fe74201f5240873de0a7251270120a Mon Sep 17 00:00:00 2001 From: Callum Gare Date: Sun, 17 Apr 2022 10:39:16 +1000 Subject: [PATCH] Fix url bug in the hooks documentation examples In a hook `event.request.url` will be a complete URL I believe (https://developer.mozilla.org/en-US/docs/Web/API/Request/url) meaning `event.request.url.startsWith('/custom')` will never be true. This commit fixes that. --- documentation/docs/05-hooks.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/05-hooks.md b/documentation/docs/05-hooks.md index 7af8403d9ab4..31c9e583c0a1 100644 --- a/documentation/docs/05-hooks.md +++ b/documentation/docs/05-hooks.md @@ -14,7 +14,7 @@ This function runs every time the SvelteKit server receives a [request](/docs/we /// file: src/hooks.js /** @type {import('@sveltejs/kit').Handle} */ export async function handle({ event, resolve }) { - if (event.request.url.startsWith('/custom')) { + if (event.url.pathname.startsWith('/custom')) { return new Response('custom response'); }