From e9e9546d75ab1a6a08793b8a91071a5535880aa1 Mon Sep 17 00:00:00 2001 From: pseudoyu Date: Fri, 27 Mar 2026 20:52:43 +0800 Subject: [PATCH] fix(route/18comic): result filter issue --- lib/routes/18comic/search.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/routes/18comic/search.ts b/lib/routes/18comic/search.ts index 04265c632..3ada20123 100644 --- a/lib/routes/18comic/search.ts +++ b/lib/routes/18comic/search.ts @@ -48,12 +48,15 @@ async function handler(ctx) { const { domain = defaultDomain } = ctx.req.query(); const rootUrl = getRootUrl(domain); let order = ctx.req.param('order') ?? 'mr'; - const currentUrl = `${rootUrl}/search/${option}${category === 'all' ? '' : `/${category}`}${keyword ? `?search_query=${keyword}` : '?'}${time === 'a' ? '' : `&t=${time}`}${order === 'mr' ? '' : `&o=${order}`}`; + // Reason: keyword may contain `+` (AND operator) and `-` (NOT operator). + // Without encoding, `+` is treated as space in query strings, breaking search logic. + const encodedKeyword = encodeURIComponent(keyword); + const currentUrl = `${rootUrl}/search/${option}${category === 'all' ? '' : `/${category}`}${keyword ? `?search_query=${encodedKeyword}` : '?'}${time === 'a' ? '' : `&t=${time}`}${order === 'mr' ? '' : `&o=${order}`}`; const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 20; let apiUrl = getApiUrl(); order = time === 'a' ? order : `${order}_${time}`; - apiUrl = `${apiUrl}/search?search_query=${keyword}&o=${order}`; + apiUrl = `${apiUrl}/search?search_query=${encodedKeyword}&o=${order}`; const apiResult = await processApiItems(apiUrl); let filteredItemsByCategory = apiResult.content; // Filter items by category if not 'all'