From 4228e31ee497c98cc04d494a15f2095a42577694 Mon Sep 17 00:00:00 2001 From: teddit Date: Wed, 31 Mar 2021 20:34:59 +0200 Subject: [PATCH] console.log instead of console.error on invalid s and send 404 response on apple favicon shit --- routes.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/routes.js b/routes.js index 1e23c9a..17ed3d9 100644 --- a/routes.js +++ b/routes.js @@ -569,8 +569,12 @@ module.exports = (app, redis, fetch, RedditAPI) => { sortby = 'hot' } + if(['apple-touch-icon.png', 'apple-touch-icon-precomposed.png', 'apple-touch-icon-120x120.png', 'apple-touch-icon-120x120-precomposed.png'].includes(sortby)) { + return res.sendStatus(404) // return 404 on shitty apple favicon stuff + } + if(!['new', 'rising', 'controversial', 'top', 'gilded', 'hot'].includes(sortby)) { - console.error(`Got invalid sort.`, req.originalUrl) + console.log(`Got invalid sort.`, req.originalUrl) return res.redirect('/') } @@ -1029,7 +1033,7 @@ module.exports = (app, redis, fetch, RedditAPI) => { } if(!['new', 'rising', 'controversial', 'top', 'gilded', 'hot'].includes(sortby)) { - console.error(`Got invalid sort.`, req.originalUrl) + console.log(`Got invalid sort.`, req.originalUrl) return res.redirect(`/r/${subreddit}`) } @@ -1167,7 +1171,7 @@ module.exports = (app, redis, fetch, RedditAPI) => { } if(!['confidence', 'top', 'new', 'controversial', 'old', 'qa', 'random'].includes(sortby)) { - console.error(`Got invalid sort.`, req.originalUrl) + console.log(`Got invalid sort.`, req.originalUrl) return res.redirect('/') } @@ -1361,7 +1365,7 @@ module.exports = (app, redis, fetch, RedditAPI) => { } if(!['hot', 'new', 'controversial', 'top'].includes(sortby)) { - console.error(`Got invalid sort.`, req.originalUrl) + console.log(`Got invalid sort.`, req.originalUrl) return res.redirect(`/u/${user}`) } @@ -1521,7 +1525,7 @@ module.exports = (app, redis, fetch, RedditAPI) => { } if(!['new', 'rising', 'controversial', 'top', 'gilded', 'hot'].includes(sortby)) { - console.error(`Got invalid sort.`, req.originalUrl) + console.log(`Got invalid sort.`, req.originalUrl) return res.redirect(`/u/${user}`) }