From f1d5db6be02c3818ba59b92d34c9d3c9cfd1c0e2 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sat, 13 Sep 2014 18:50:35 -0400 Subject: [PATCH] pagination fix --- src/controllers/topics.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/topics.js b/src/controllers/topics.js index c955f25cbf..bb772d1dac 100644 --- a/src/controllers/topics.js +++ b/src/controllers/topics.js @@ -74,8 +74,8 @@ topicsController.get = function(req, res, next) { postIndex = Math.max((req.params.post_index || 1) - (settings.postsPerPage + 1), 0); } } else if (!req.query.page) { - var index = Math.max(req.params.post_index, 0); - page = Math.ceil((index + 1) / settings.postsPerPage); + var index = Math.max(req.params.post_index - 1, 0); + page = Math.max(1, Math.ceil(index / settings.postsPerPage)); } var start = (page - 1) * settings.postsPerPage + postIndex,