Node.js based forum software built for the modern web
removed checks that would send the user to 404 if the slug didn't match, restored old behaviour of redirecting to the correct slug. #3047
Julian Lam8ee40ece7167
diff --git a/src/controllers/categories.js b/src/controllers/categories.jsindex d3bc62d6a3..e86bbce574 100644--- a/src/controllers/categories.js+++ b/src/controllers/categories.js@@ -188,15 +188,11 @@ categoriesController.get = function(req, res, next) {return helpers.notFound(req, res);}- if (req.params.slug && cid + '/' + req.params.slug !== results.categoryData.slug) {- return helpers.notFound(req, res);- }-if (!results.privileges.read) {return helpers.notAllowed(req, res);}- if (!req.params.slug && results.categoryData.slug && results.categoryData.slug !== cid + '/') {+ if ((!req.params.slug || results.categoryData.slug !== cid + '/' + req.params.slug) && (results.categoryData.slug && results.categoryData.slug !== cid + '/')) {return helpers.redirect(res, '/category/' + encodeURI(results.categoryData.slug));}diff --git a/src/controllers/topics.js b/src/controllers/topics.jsindex b7c27324ee..4e2ade5868 100644--- a/src/controllers/topics.js+++ b/src/controllers/topics.js@@ -43,15 +43,11 @@ topicsController.get = function(req, res, next) {function (results, next) {userPrivileges = results.privileges;- if (userPrivileges.disabled || (req.params.slug && tid + '/' + req.params.slug !== results.topic.slug)) {- return helpers.notFound(req, res);- }-if (!userPrivileges.read || (parseInt(results.topic.deleted, 10) && !userPrivileges.view_deleted)) {return helpers.notAllowed(req, res);}- if (!req.params.slug && results.topic.slug && results.topic.slug !== tid + '/') {+ if ((!req.params.slug || results.topic.slug !== tid + '/' + req.params.slug) && (results.topic.slug && results.topic.slug !== tid + '/')) {return helpers.redirect(res, '/topic/' + encodeURI(results.topic.slug));}