From 651f51c4aad6844b78fdc38de5ca8f833955273f Mon Sep 17 00:00:00 2001 From: Andvari <31068367+dzx-dzx@users.noreply.github.com> Date: Tue, 22 Oct 2024 01:35:40 +0800 Subject: [PATCH] fix(route): Correct misuse of `fulltext` query (#17230) * Update common.ts * . --- lib/routes/apnews/api.ts | 2 +- lib/routes/apnews/rss.ts | 2 +- lib/routes/apnews/sitemap.ts | 2 +- lib/routes/apnews/topics.ts | 2 +- lib/routes/reuters/common.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/routes/apnews/api.ts b/lib/routes/apnews/api.ts index c0c0372f4b6590..f0edc8582bb5e3 100644 --- a/lib/routes/apnews/api.ts +++ b/lib/routes/apnews/api.ts @@ -67,7 +67,7 @@ async function handler(ctx) { .sort((a, b) => b.pubDate - a.pubDate) .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 20); - const items = ctx.req.query('mode') === 'fulltext' ? await Promise.all(list.map((item) => fetchArticle(item))) : list; + const items = ctx.req.query('fulltext') === 'true' ? await Promise.all(list.map((item) => fetchArticle(item))) : list; return { title: `${res.tagObjs[0].name} - AP News`, diff --git a/lib/routes/apnews/rss.ts b/lib/routes/apnews/rss.ts index 8402bde6a31505..c14ad46713dfb4 100644 --- a/lib/routes/apnews/rss.ts +++ b/lib/routes/apnews/rss.ts @@ -38,7 +38,7 @@ async function handler(ctx) { const url = `${HOME_PAGE}/${rss}.rss`; const res = await parser.parseURL(url); - const items = ctx.req.query('mode') === 'fulltext' ? await Promise.all(res.items.map((item) => fetchArticle(item))) : res; + const items = ctx.req.query('fulltext') === 'true' ? await Promise.all(res.items.map((item) => fetchArticle(item))) : res; return { ...res, diff --git a/lib/routes/apnews/sitemap.ts b/lib/routes/apnews/sitemap.ts index 066ded45595d42..655ab7f088d01f 100644 --- a/lib/routes/apnews/sitemap.ts +++ b/lib/routes/apnews/sitemap.ts @@ -81,7 +81,7 @@ async function handler(ctx) { .sort((a, b) => (a.pubDate && b.pubDate ? b.pubDate - a.pubDate : b.lastmod - a.lastmod)) .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 20); - const items = ctx.req.query('mode') === 'fulltext' ? await asyncPoolAll(20, list, (item) => fetchArticle(item)) : list; + const items = ctx.req.query('fulltext') === 'true' ? await asyncPoolAll(20, list, (item) => fetchArticle(item)) : list; return { title: `AP News sitemap:${route}`, diff --git a/lib/routes/apnews/topics.ts b/lib/routes/apnews/topics.ts index 92bb1b070a8c42..66a31bd3a5fc41 100644 --- a/lib/routes/apnews/topics.ts +++ b/lib/routes/apnews/topics.ts @@ -50,7 +50,7 @@ async function handler(ctx) { link: $(e).find('a').attr('href'), })) .filter((e) => typeof e.link === 'string') - .map((item) => (ctx.req.query('mode') === 'fulltext' ? fetchArticle(item) : item)) + .map((item) => (ctx.req.query('fulltext') === 'true' ? fetchArticle(item) : item)) ); return { diff --git a/lib/routes/reuters/common.ts b/lib/routes/reuters/common.ts index 74e7ff10845ee6..6521ae77b07d02 100644 --- a/lib/routes/reuters/common.ts +++ b/lib/routes/reuters/common.ts @@ -190,7 +190,7 @@ async function handler(ctx) { const results = await Promise.allSettled( items.map((item) => - ctx.req.query('mode') === 'fulltext' + ctx.req.query('fulltext') === 'true' ? cache.tryGet(item.link, async () => { const detailResponse = await ofetch(item.link); const content = load(detailResponse.data);