diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-02-05 16:07:31 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-02-05 16:08:55 -0400 |
commit | 4d5465b69989d50131ade81bc1cb8a929c64fc70 (patch) | |
tree | e286d438b636409924fe82411673f5dbdec8f873 /src/write/build-modes/live-dev-server.js | |
parent | 2cd8c5b4b7a9e674900cdecfeee7c3bd850124bd (diff) |
write: static-build, live-dev-server: path.condition()
Diffstat (limited to 'src/write/build-modes/live-dev-server.js')
-rw-r--r-- | src/write/build-modes/live-dev-server.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index 28969de2..cd84dcc0 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -389,7 +389,11 @@ export async function go({ // URL to page map expects trailing slash but no leading slash. const pathnameKey = pathname.replace(/^\//, '') + (pathname.endsWith('/') ? '' : '/'); - if (!Object.hasOwn(urlToPageMap, pathnameKey)) { + const is404 = + !Object.hasOwn(urlToPageMap, pathnameKey) || + !(urlToPageMap[pathnameKey].page.condition?.() ?? true); + + if (is404) { response.writeHead(404, contentTypePlain); response.end(`No page found for: ${pathnameKey}\n`); if (loudResponses) console.log(`${requestHead} [404] ${pathname} (no page)`); |