diff --git a/routes.js b/routes.js index 0442182..34e9389 100644 --- a/routes.js +++ b/routes.js @@ -965,19 +965,11 @@ module.exports = (app, redis, fetch, RedditAPI) => { if(json) { console.log(`Got /r/${subreddit} wiki key from redis.`) json = JSON.parse(json) - if(page !== 'pages') { - return res.render('subreddit_wiki', { - content_html: unescape(json.data.content_html), - subreddit: subreddit, - user_preferences: req.cookies - }) - } else { - return res.render('subreddit_wiki', { - content_html: formatWikipagelisting(json, subreddit), - subreddit: subreddit, - user_preferences: req.cookies - }) - } + return res.render('subreddit_wiki', { + content_html: (page !== 'pages' ? unescape(json.data.content_html) : formatWikipagelisting(json, subreddit)), + subreddit: subreddit, + user_preferences: req.cookies + }) } else { let url = '' if(config.use_reddit_oauth) @@ -995,19 +987,11 @@ module.exports = (app, redis, fetch, RedditAPI) => { return res.render('subreddit', { json: null, user_preferences: req.cookies }) } else { console.log(`Fetched the JSON from reddit.com/r/${subreddit}/wiki.`) - if(page !== 'pages') { - return res.render('subreddit_wiki', { - content_html: unescape(json.data.content_html), - subreddit: subreddit, - user_preferences: req.cookies - }) - } else { - return res.render('subreddit_wiki', { - content_html: formatWikipagelisting(json, subreddit), - subreddit: subreddit, - user_preferences: req.cookies - }) - } + return res.render('subreddit_wiki', { + content_html: (page !== 'pages' ? unescape(json.data.content_html) : formatWikipagelisting(json, subreddit)), + subreddit: subreddit, + user_preferences: req.cookies + }) } }) })