From 05a4737e84fa7a6c7b3b75eb3ba3e68f2f491863 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 14 Nov 2014 11:32:56 -0500 Subject: [PATCH] closes #2409 --- src/categories.js | 1 + src/controllers/categories.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/categories.js b/src/categories.js index bf0a94fde9..cc23c3afba 100644 --- a/src/categories.js +++ b/src/categories.js @@ -168,6 +168,7 @@ var async = require('async'), category.name = validator.escape(category.name); category.disabled = parseInt(category.disabled, 10) === 1; category.icon = category.icon || 'hidden'; + category.post_count = category.post_count || 0; if (category.description) { category.description = validator.escape(category.description); diff --git a/src/controllers/categories.js b/src/controllers/categories.js index f7feab3874..dae575080a 100644 --- a/src/controllers/categories.js +++ b/src/controllers/categories.js @@ -142,7 +142,7 @@ categoriesController.get = function(req, res, next) { var topicIndex = utils.isNumber(req.params.topic_index) ? parseInt(req.params.topic_index, 10) - 1 : 0; var topicCount = parseInt(results.categoryData.topic_count, 10); - if (topicIndex < 0 || topicIndex > topicCount - 1) { + if (topicIndex < 0 || topicIndex > Math.max(topicCount - 1, 0)) { var url = '/category/' + cid + '/' + req.params.slug + (topicIndex > topicCount ? '/' + topicCount : ''); return res.locals.isAPI ? res.status(302).json(url) : res.redirect(url); }