Skip to content

Commit

Permalink
fix(route): Correct misuse of fulltext query (#17230)
Browse files Browse the repository at this point in the history
* Update common.ts

* .
  • Loading branch information
dzx-dzx authored Oct 21, 2024
1 parent 96436e8 commit 651f51c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/routes/apnews/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/apnews/rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/apnews/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/apnews/topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/reuters/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 651f51c

Please sign in to comment.