fix(route): bbc incorrect section in title (#15502)
* fix: incorrect section in title * fix: remove String()
This commit is contained in:
+16
-8
@@ -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($);
|
||||
const path = new URL(item.link).pathname;
|
||||
|
||||
let section = 'sport';
|
||||
const urlSplit = item.link.split('/');
|
||||
const sectionSplit = urlSplit.at(-1).split('-');
|
||||
if (sectionSplit.length > 1) {
|
||||
section = sectionSplit[0];
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user