diff --git a/lib/routes/apnews/topics.ts b/lib/routes/apnews/topics.ts index 2379614b1bb38c..283c8e0837f5fb 100644 --- a/lib/routes/apnews/topics.ts +++ b/lib/routes/apnews/topics.ts @@ -43,7 +43,7 @@ async function handler(ctx) { link: $(e).find('a').attr('href'), })) .filter((e) => typeof e.link === 'string') - .map((item) => (new URL(item.link).hostname === 'apnews.com' ? fetchArticle(item) : item)) + .map((item) => fetchArticle(item)) ); return { diff --git a/lib/routes/apnews/utils.ts b/lib/routes/apnews/utils.ts index 0b75aaa92dcc3d..a6c239223b9c4c 100644 --- a/lib/routes/apnews/utils.ts +++ b/lib/routes/apnews/utils.ts @@ -7,6 +7,9 @@ export function fetchArticle(item) { return cache.tryGet(item.link, async () => { const data = await ofetch(item.link); const $ = load(data); + if ($('#link-ld-json').length === 0) { + return item; + } const rawLdjson = JSON.parse($('#link-ld-json').text()); let ldjson; if (Array.isArray(rawLdjson)) {