move slug handling to middleware #12632

This commit is contained in:
Barış Soner Uşaklı
2024-06-11 16:24:56 -04:00
parent 5c6a853e94
commit 17cd3b684c
2 changed files with 10 additions and 10 deletions

View File

@@ -15,16 +15,6 @@ const utils = require('../../utils');
const profileController = module.exports;
profileController.get = async function (req, res, next) {
const lowercaseSlug = req.params.userslug.toLowerCase();
if (req.params.userslug !== lowercaseSlug) {
if (res.locals.isAPI) {
req.params.userslug = lowercaseSlug;
} else {
return res.redirect(`${nconf.get('relative_path')}/user/${lowercaseSlug}`);
}
}
const { userData } = res.locals;
if (!userData) {
return next();