From 3f998a9081f5a0955727a1389975103047a25e64 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 14 Mar 2016 13:03:33 -0400 Subject: [PATCH] Updated topic and category controller to not redirect on incorrect slug if the call is made via API route. Cold load? Anything goes. --- src/controllers/category.js | 2 +- src/controllers/topics.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/category.js b/src/controllers/category.js index f4b939f60a..e3adde496f 100644 --- a/src/controllers/category.js +++ b/src/controllers/category.js @@ -51,7 +51,7 @@ categoryController.get = function(req, res, callback) { return helpers.notAllowed(req, res); } - if ((!req.params.slug || results.categoryData.slug !== cid + '/' + req.params.slug) && (results.categoryData.slug && results.categoryData.slug !== cid + '/')) { + if (!res.locals.isAPI && (!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.js index 7a222dd09c..68a3b18415 100644 --- a/src/controllers/topics.js +++ b/src/controllers/topics.js @@ -54,7 +54,7 @@ topicsController.get = function(req, res, callback) { return helpers.notAllowed(req, res); } - if ((!req.params.slug || results.topic.slug !== tid + '/' + req.params.slug) && (results.topic.slug && results.topic.slug !== tid + '/')) { + if (!res.locals.isAPI && (!req.params.slug || results.topic.slug !== tid + '/' + req.params.slug) && (results.topic.slug && results.topic.slug !== tid + '/')) { var url = '/topic/' + encodeURI(results.topic.slug); if (req.params.post_index){ url += '/'+req.params.post_index;