Skip to content

Commit

Permalink
fix: don't skip invalid URL but throw error instead
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Sep 4, 2024
1 parent fe38737 commit 2800dff
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion vike/node/runtime/renderPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit 2800dff

Please sign in to comment.