From 69d3550b1e9a51bb9c8ab2cfeb8fb4a4ffa4c4e0 Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Mon, 8 Jul 2019 04:47:56 +0100 Subject: [PATCH] fix: remove a redundant condition check (#2578) Condition 'list' is always true. The value of variable 'list' is originated from the array created at line 20 . --- lib/routes/rsshub/rss.js | 44 +++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/lib/routes/rsshub/rss.js b/lib/routes/rsshub/rss.js index 7aafa589d..f2f729915 100644 --- a/lib/routes/rsshub/rss.js +++ b/lib/routes/rsshub/rss.js @@ -28,28 +28,26 @@ module.exports = async (ctx) => { title: 'RSSHub 有新路由啦', link: 'https://docs.rsshub.app', description: '万物皆可 RSS', - item: - list && - list.map(({ item, type }) => { - item = cheerio(item); - item.find('.header-anchor').remove(); - const titleEle = item.prevAll('h2').eq(0); - return { - title: `${titleEle[0].attribs.id} - ${item - .prevAll('h3') - .eq(0) - .text() - .slice(2)}`, - description: item.html(), - link: `https://docs.rsshub.app/${type}.html#${encodeURIComponent( - titleEle.find('.header-anchor').attr('href') && - titleEle - .find('.header-anchor') - .attr('href') - .slice(1) - )}`, - guid: item.attr('id'), - }; - }), + item: list.map(({ item, type }) => { + item = cheerio(item); + item.find('.header-anchor').remove(); + const titleEle = item.prevAll('h2').eq(0); + return { + title: `${titleEle[0].attribs.id} - ${item + .prevAll('h3') + .eq(0) + .text() + .slice(2)}`, + description: item.html(), + link: `https://docs.rsshub.app/${type}.html#${encodeURIComponent( + titleEle.find('.header-anchor').attr('href') && + titleEle + .find('.header-anchor') + .attr('href') + .slice(1) + )}`, + guid: item.attr('id'), + }; + }), }; };