From d516472f83fca9c90171af0b448c339b91380c1a Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Thu, 16 Jan 2020 06:21:06 +0000 Subject: [PATCH] fix: gbcc/trust GUIDs are not unique (#3747) --- lib/routes/gbcc/trust.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/routes/gbcc/trust.js b/lib/routes/gbcc/trust.js index d6fe972bb8..eec3cf0bd8 100644 --- a/lib/routes/gbcc/trust.js +++ b/lib/routes/gbcc/trust.js @@ -8,15 +8,17 @@ module.exports = async (ctx) => { const $ = cheerio.load(response); const items = $('.entry-anchorLinkId') - .next('.entry-text') - .map((i, e) => ({ - title: $(e) - .find('h1') - .html(), - link, - description: $(e).html(), - pubDate: new Date().toUTCString(), - })) + .map((i, e) => { + const text = $(e).next('.entry-text'); + return { + title: $(text) + .find('h1') + .html(), + link: `${link}#${$(e).children('div')[0].attribs.id}`, + description: $(text).html(), + pubDate: new Date().toUTCString(), + }; + }) .get(); ctx.state.data = {