From 2800dfff4314fabac8dc245d5ca9e7d3b328f619 Mon Sep 17 00:00:00 2001 From: Romuald Brillout Date: Wed, 4 Sep 2024 12:49:44 +0200 Subject: [PATCH] fix: don't skip invalid URL but throw error instead --- vike/node/runtime/renderPage.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/vike/node/runtime/renderPage.ts b/vike/node/runtime/renderPage.ts index b72fb756c4a..72cbb6466d8 100644 --- a/vike/node/runtime/renderPage.ts +++ b/vike/node/runtime/renderPage.ts @@ -91,6 +91,7 @@ async function renderPage< assertArguments(...arguments) assert(hasProp(pageContextInit, 'urlOriginal', 'string')) // assertUsage() already implemented at assertArguments() assertEnv() + assertIsUrl(pageContextInit.urlOriginal) assertIsNotViteRequest(pageContextInit.urlOriginal) if (isIgnoredUrl(pageContextInit.urlOriginal)) { @@ -474,7 +475,15 @@ function getRequestId(): number { } function isIgnoredUrl(urlOriginal: string): boolean { - return urlOriginal.endsWith('/favicon.ico') || !isUrl(urlOriginal) + return urlOriginal.endsWith('/favicon.ico') +} +function assertIsUrl(urlOriginal: string) { + assertUsage( + isUrl(urlOriginal), + `${pc.code('renderPage(pageContextInit)')} (https://vike.dev/renderPage) called with ${pc.code( + `pageContextInit.urlOriginal===${JSON.stringify(urlOriginal)}` + )} which isn't a valid URL` + ) } function assertIsNotViteRequest(urlOriginal: string) { const isViteRequest =