From 5e2cbc1ee73114791a87dfd58198f75038e9337c Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Tue, 7 May 2024 17:11:58 +0100 Subject: [PATCH] fix(route): bbc incorrect section in title (#15502) * fix: incorrect section in title * fix: remove String() --- lib/routes/bbc/index.ts | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/routes/bbc/index.ts b/lib/routes/bbc/index.ts index 88ce4dd780eb0b..320b85aa377005 100644 --- a/lib/routes/bbc/index.ts +++ b/lib/routes/bbc/index.ts @@ -65,18 +65,26 @@ async function handler(ctx) { const $ = load(response); - const description = new URL(item.link).pathname.startsWith('/news/av') ? item.content : utils.ProcessFeed($); - - let section = 'sport'; - const urlSplit = item.link.split('/'); - const sectionSplit = urlSplit.at(-1).split('-'); - if (sectionSplit.length > 1) { - section = sectionSplit[0]; + const path = new URL(item.link).pathname; + + let description; + + switch (true) { + case path.startsWith('/sport'): + description = item.content; + break; + case path.startsWith('/sounds/play'): + description = item.content; + break; + case path.startsWith('/news/live'): + description = item.content; + break; + default: + description = utils.ProcessFeed($); } - section = section[0].toUpperCase() + section.slice(1); return { - title: `[${section}] ${item.title}`, + title: item.title, description, pubDate: item.pubDate, link: item.link,