From 9916c348bb05873dcfe6d33108a40c7dc93bd79e Mon Sep 17 00:00:00 2001 From: XieSC Date: Sun, 27 Oct 2024 01:38:35 +0800 Subject: [PATCH] fix(route): get correct item link (#17278) When the `href` link inside the element is a relative link, the original handling would obtain an incorrect full link --- lib/routes/rsshub/transform/html.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/routes/rsshub/transform/html.ts b/lib/routes/rsshub/transform/html.ts index 1084bf240..c4354c168 100644 --- a/lib/routes/rsshub/transform/html.ts +++ b/lib/routes/rsshub/transform/html.ts @@ -92,10 +92,10 @@ Specify options (in the format of query string) in parameter \`routeParams\` par } else { link = linkEle.is('a') ? linkEle.attr('href') : linkEle.find('a').attr('href'); } - // 补全绝对链接 + // 补全绝对链接或相对链接 link = link.trim(); if (link && !link.startsWith('http')) { - link = `${new URL(url).origin}${link}`; + link = (new URL(link, url)).href; } const descEle = routeParams.get('itemDesc') ? item.find(routeParams.get('itemDesc')) : item;