small fix to redirect

v1.18.x
barisusakli 11 years ago
parent 61b79de3e8
commit 8d0c659f08

@ -86,9 +86,9 @@ middleware.checkPostIndex = function(req, res, next) {
} }
var postIndex = parseInt(req.params.post_index, 10); var postIndex = parseInt(req.params.post_index, 10);
if (postIndex > postCount) { if (postIndex > postCount) {
return res.redirect('/topic/' + req.params.topic_id + '/' + req.params.slug + '/' + postCount); 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) { } 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) : res.redirect('/topic/' + req.params.topic_id + '/' + req.params.slug);
} }
next(); next();
}); });

Loading…
Cancel
Save