From 1932e597ad3664682428284ff581b0f4e939ae02 Mon Sep 17 00:00:00 2001 From: fatchan Date: Wed, 3 Jul 2019 22:12:06 +0000 Subject: [PATCH] page number bug when 0 posts, page is always above maxpages of 0 --- models/pages/board.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/pages/board.js b/models/pages/board.js index 47a7bb2e..effacccf 100644 --- a/models/pages/board.js +++ b/models/pages/board.js @@ -8,8 +8,8 @@ module.exports = async (req, res, next) => { const page = req.params.page === 'index' ? 1 : req.params.page; try { - const maxPage = Math.min(Math.ceil((await Posts.getPages(req.params.board)) / 10), Math.ceil(res.locals.board.settings.threadLimit/10)); - if (page > maxPage && maxPage > 0) { + const maxPage = Math.min(Math.ceil((await Posts.getPages(req.params.board)) / 10), Math.ceil(res.locals.board.settings.threadLimit/10)) || 1; + if (page > maxPage) { return next(); } await buildBoard(res.locals.board, page, maxPage);