From 832430ed371f6c3bfb484612e530b12b9ce58a64 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 5 Feb 2015 18:07:17 -0500 Subject: [PATCH] dont crash if post.user or post.category doesn't exist --- src/search.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/search.js b/src/search.js index 3360f09273..9f260cd7cc 100644 --- a/src/search.js +++ b/src/search.js @@ -99,8 +99,8 @@ function filterPosts(data, searchCategories, posts) { if (postedBy || searchCategories.length || data.replies) { posts = posts.filter(function(post) { return post && - (postedBy ? (post.user && post.user.username) === postedBy : true) && - (searchCategories.length ? searchCategories.indexOf(post.category.cid) !== -1 : true) && + (postedBy ? post.user && (post.user.username === postedBy) : true) && + (searchCategories.length ? (post.category && searchCategories.indexOf(post.category.cid) !== -1) : true) && (data.replies ? (isAtLeast ? post.topic.postcount >= data.replies : post.topic.postcount <= data.replies) : true); }); }