From b35d47d68519f55be0cc0fa739aa3212940d3d19 Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 5 Dec 2024 22:19:39 +0800 Subject: [PATCH] fix(36kr): add checks --- lib/routes/36kr/hot-list.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/routes/36kr/hot-list.ts b/lib/routes/36kr/hot-list.ts index 46b072ddd..b546d4b14 100644 --- a/lib/routes/36kr/hot-list.ts +++ b/lib/routes/36kr/hot-list.ts @@ -4,6 +4,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { rootUrl, ProcessItem } from './utils'; +import InvalidParameterError from '@/errors/types/invalid-parameter'; const categories = { 24: { @@ -54,6 +55,10 @@ export const route: Route = { async function handler(ctx) { const category = ctx.req.param('category') ?? '24'; + if (!categories[category]) { + throw new InvalidParameterError('This category does not exist. Please refer to the documentation for the correct usage.'); + } + const currentUrl = category === '24' ? rootUrl : `${rootUrl}/hot-list/catalog`; const response = await got({