diff --git a/src/server.mjs b/src/server.mjs index 65aa0dce..f6c71313 100644 --- a/src/server.mjs +++ b/src/server.mjs @@ -93,16 +93,11 @@ app.use(helmet({ // This takes one of those files and displays it for a site visitor. // Query strings like /?j are converted into paths like /views/hidden.html // back here. Which query string converts to what is defined in routes.mjs. -router.get('/', async (req, res) => { - const paramKey = Object.keys(req.query)[0]; - const filePath = paramKey ? pages[paramKey] : pages.index; - - const validPath = filePath || pages.index; - - res.send(paintSource(loadTemplates(tryReadFile( - path.join(__dirname, 'views', validPath) - )))); - }); +router.get('/', async (req, res) => res.send(paintSource(loadTemplates(tryReadFile( +// Return the index page if the query is not found. +// Also sets it as the default page. + path.join(__dirname, 'views', pages[Object.keys(req.query)[0] || 'index'] || pages.index) + ))))); app.use(router);