From 209edf182ff7a09d7caa8034f64cda9e659afe17 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sat, 1 Nov 2014 17:55:39 -0400 Subject: [PATCH] 404 pages that are out of range --- src/controllers/topics.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/controllers/topics.js b/src/controllers/topics.js index c816f29ecb..5c0f9f8d47 100644 --- a/src/controllers/topics.js +++ b/src/controllers/topics.js @@ -58,7 +58,10 @@ topicsController.get = function(req, res, next) { return categoriesController.notAllowed(req, res); } + var settings = results.settings; var postCount = parseInt(results.postCount, 10); + var pageCount = Math.ceil((postCount - 1) / settings.postsPerPage); + if (utils.isNumber(req.params.post_index)) { var url = ''; if (req.params.post_index > postCount) { @@ -70,7 +73,10 @@ topicsController.get = function(req, res, next) { } } - var settings = results.settings; + if (settings.usePagination && (req.query.page < 1 || req.query.page > pageCount)) { + return categoriesController.notFound(req, res); + } + var set = 'tid:' + tid + ':posts', reverse = false; @@ -120,7 +126,7 @@ topicsController.get = function(req, res, next) { return categoriesController.notAllowed(req, res); } - topicData.pageCount = Math.ceil((postCount - 1) / settings.postsPerPage); + topicData.pageCount = pageCount; topicData.currentPage = page; if(page > 1) {