small fix to redirect

This commit is contained in:
barisusakli
2014-06-04 19:54:29 -04:00
parent 61b79de3e8
commit 8d0c659f08

View File

@@ -86,9 +86,9 @@ middleware.checkPostIndex = function(req, res, next) {
}
var postIndex = parseInt(req.params.post_index, 10);
if (postIndex > postCount) {
return res.redirect('/topic/' + req.params.topic_id + '/' + req.params.slug + '/' + postCount);
} else if (postIndex <= 1) {
return res.redirect('/topic/' + req.params.topic_id + '/' + req.params.slug);
return res.locals.isAPI ? res.json(302, '/topic/' + req.params.topic_id + '/' + req.params.slug + '/' + postCount) : res.redirect('/topic/' + req.params.topic_id + '/' + req.params.slug + '/' + postCount);
} else if (postIndex < 1) {
return res.locals.isAPI ? res.json(302, '/topic/' + req.params.topic_id + '/' + req.params.slug) : res.redirect('/topic/' + req.params.topic_id + '/' + req.params.slug);
}
next();
});