diff --git a/lib/v2/yahoo/news/tw/provider.js b/lib/v2/yahoo/news/tw/provider.js index 40332d3d55..14791c1be2 100644 --- a/lib/v2/yahoo/news/tw/provider.js +++ b/lib/v2/yahoo/news/tw/provider.js @@ -9,19 +9,15 @@ module.exports = async (ctx) => { const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 20; const providerList = await getProviderList(region, ctx.cache.tryGet); const provider = providerList.find((p) => p.key === providerId); - if (!provider) { - throw Error(`Unknown providerId: ${providerId} - Please double check the provider list.`); - } - const response = await getArchive(region, limit, null, provider.key); + const response = await getArchive(region, limit, null, providerId); const list = parseList(region, response); const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet))); ctx.state.data = { - title: `Yahoo 新聞 - ${provider.title}`, - link: provider.link, + title: `Yahoo 新聞 - ${provider?.title ?? ''}`, + link: provider?.link ?? `https://${region}.news.yahoo.com`, image: 'https://s.yimg.com/cv/apiv2/social/images/yahoo_default_logo-1200x1200.png', item: items, };