From cf2fe7f9f11844da9e73da54cb4f6574a57b4cbe Mon Sep 17 00:00:00 2001 From: teddit Date: Fri, 29 Jan 2021 20:09:26 +0100 Subject: [PATCH] fix /user/ redirect route --- routes.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/routes.js b/routes.js index 2348cd6..75aee11 100644 --- a/routes.js +++ b/routes.js @@ -1001,11 +1001,20 @@ module.exports = (app, redis, fetch, RedditAPI) => { }) }) - app.get('/user/:user', (req, res, next) => { - res.redirect(`/u/${req.params.user}`) + app.get('/user/:user/:kind?', (req, res, next) => { + let kind = '' + if(req.params.kind) + kind = `/${req.params.kind}` + let q = '' + if(req.query.sort) + q += `?sort=${req.query.sort}&` + if(req.query.t) + q += `t=${req.query.t}` + + res.redirect(`/u/${req.params.user}${kind}${q}`) }) - app.get('/u/:user/:kind?/:sort?', (req, res, next) => { + app.get('/u/:user/:kind?', (req, res, next) => { let user = req.params.user let after = req.query.after let before = req.query.before