From 7e3535b88ba46f75e30acf479bd00688bce3a588 Mon Sep 17 00:00:00 2001 From: StevenNMeza Date: Fri, 19 Mar 2021 19:20:12 +0100 Subject: [PATCH] Do not run a search if there is no query --- routes.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/routes.js b/routes.js index 10aff1d..e0ce46e 100644 --- a/routes.js +++ b/routes.js @@ -719,6 +719,21 @@ module.exports = (app, redis, fetch, RedditAPI) => { app.get('/r/:subreddit/search', (req, res, next) => { let subreddit = req.params.subreddit let q = req.query.q + + if (typeof q === "undefined") { + return res.render('search', { + json: { posts: [] }, + no_query: true, + q: '', + restrict_sr: undefined, + nsfw: undefined, + subreddit: subreddit, + sortby: undefined, + past: undefined, + user_preferences: req.cookies + }) + } + let restrict_sr = req.query.restrict_sr let nsfw = req.query.nsfw let sortby = req.query.sort