From 8203cc8f819dbe60f713947a36240c6911ab5ad0 Mon Sep 17 00:00:00 2001 From: ashley Date: Fri, 31 May 2024 11:40:18 +0000 Subject: [PATCH] add a 404 to games if it doesnt exist :3 --- src/libpoketube/init/pages-static.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/libpoketube/init/pages-static.js b/src/libpoketube/init/pages-static.js index a8a75e72..b9afccd2 100644 --- a/src/libpoketube/init/pages-static.js +++ b/src/libpoketube/init/pages-static.js @@ -210,11 +210,20 @@ module.exports = function (app, config, renderTemplate) { } }); - app.get("/game-hub", function (req, res) { - renderTemplate(res, req, "gamehub.ejs", { - game: req.query.game, - }); +app.get("/game-hub", function (req, res) { + var gameslist = ["pong", "tic-tac-toe", "sudoku", "snake"]; + var requestedGame = req.query.game; + + if (!requestedGame || !gameslist.includes(requestedGame)) { + return renderTemplate(res, req, "404.ejs"); + } + + renderTemplate(res, req, "gamehub.ejs", { + game: requestedGame, }); +}); + + app.get("/static/:id", (req, res) => { const id = req.params.id;