From d1273516b54f02eb55fc8ff4977a7bbe055b0114 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 21 Sep 2014 10:12:20 +0200 Subject: [PATCH] default for missing post_index parameter Avoid getting NaN if post_index param is not set (NaN is passed through to redis, redis complains, and the user ends up at /404) --- src/controllers/topics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/topics.js b/src/controllers/topics.js index bfc2b4e396..f710e1119d 100644 --- a/src/controllers/topics.js +++ b/src/controllers/topics.js @@ -72,7 +72,7 @@ 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(parseInt(req.params.post_index, 10), 0); + var index = Math.max(parseInt(req.params.post_index, 10), 0) || 0; page = Math.ceil((index + 1) / settings.postsPerPage); }