From f8ad03ea2942cb680d0e9fcd927190c63dd62f67 Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Tue, 21 May 2024 20:36:24 +0100 Subject: [PATCH] fix(route): FT route conflict (#15649) * fix: FT route conflict closes #15641 * fix: param --- lib/routes/ft/namespace.ts | 2 +- lib/routes/{ft => ftchinese}/channel.ts | 10 +++++----- lib/routes/ftchinese/namespace.ts | 6 ++++++ lib/routes/{ft => ftchinese}/utils.ts | 0 4 files changed, 12 insertions(+), 6 deletions(-) rename lib/routes/{ft => ftchinese}/channel.ts (71%) create mode 100644 lib/routes/ftchinese/namespace.ts rename lib/routes/{ft => ftchinese}/utils.ts (100%) diff --git a/lib/routes/ft/namespace.ts b/lib/routes/ft/namespace.ts index 619b11640..aa55ed143 100644 --- a/lib/routes/ft/namespace.ts +++ b/lib/routes/ft/namespace.ts @@ -2,5 +2,5 @@ import type { Namespace } from '@/types'; export const namespace: Namespace = { name: 'Financial Times', - url: 'ftchinese.com', + url: 'ft.com', }; diff --git a/lib/routes/ft/channel.ts b/lib/routes/ftchinese/channel.ts similarity index 71% rename from lib/routes/ft/channel.ts rename to lib/routes/ftchinese/channel.ts index 47978c9c5..ad2f6eb0e 100644 --- a/lib/routes/ft/channel.ts +++ b/lib/routes/ftchinese/channel.ts @@ -4,8 +4,8 @@ import utils from './utils'; export const route: Route = { path: '/:language/:channel?', categories: ['traditional-media'], - example: '/ft/chinese/hotstoryby7day', - parameters: { language: '语言,简体`chinese`,繁体`traditional`', channel: '频道,缺省为每日更新' }, + example: '/ft/simplified/hotstoryby7day', + parameters: { language: '语言,简体 `simplified`,繁体 `traditional`', channel: '频道,缺省为每日更新' }, features: { requireConfig: false, requirePuppeteer: false, @@ -25,13 +25,13 @@ export const route: Route = { 支持所有频道,频道名称见 [官方频道 RSS](http://www.ftchinese.com/channel/rss.html). - - 频道为单一路径,如 \`http://www.ftchinese.com/rss/news\` 则为 \`/ft/chinese/news\`. - - 频道包含多重路径,如 \`http://www.ftchinese.com/rss/column/007000002\` 则替换 \`/\` 为 \`-\` \`/ft/chinese/column-007000002\`.`, + - 频道为单一路径,如 \`http://www.ftchinese.com/rss/news\` 则为 \`/ft/simplified/news\`. + - 频道包含多重路径,如 \`http://www.ftchinese.com/rss/column/007000002\` 则替换 \`/\` 为 \`-\` \`/ft/simplified/column-007000002\`.`, }; async function handler(ctx) { return await utils.getData({ - site: ctx.req.param('language') === 'chinese' ? 'www' : 'big5', + site: ctx.req.param('language') === 'simplified' ? 'www' : 'big5', channel: ctx.req.param('channel'), ctx, }); diff --git a/lib/routes/ftchinese/namespace.ts b/lib/routes/ftchinese/namespace.ts new file mode 100644 index 000000000..dd0ac1d52 --- /dev/null +++ b/lib/routes/ftchinese/namespace.ts @@ -0,0 +1,6 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'FT 中文网', + url: 'ftchinese.com', +}; diff --git a/lib/routes/ft/utils.ts b/lib/routes/ftchinese/utils.ts similarity index 100% rename from lib/routes/ft/utils.ts rename to lib/routes/ftchinese/utils.ts