From 8278ec5893d83c1df024d7f73f32cdc7dfaa5c58 Mon Sep 17 00:00:00 2001 From: grassblock Date: Thu, 31 Jul 2025 18:34:22 +0800 Subject: [PATCH] fix: only the path is returned when redirect location is a path --- core/link.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/link.py b/core/link.py index 9dae7e9..eb0ab41 100644 --- a/core/link.py +++ b/core/link.py @@ -52,7 +52,12 @@ async def extend_short_urls(url): if not url: return url if r.status in [301, 302, 304, 307, 308] and 'Location' in r.headers: - return r.headers['Location'] + if 'http' in r.headers['Location']: + return r.headers['Location'] + else: + # 如果 Location 头部没有 http 前缀,可能是相对路径 + # 需要将其转换正确的链接 + return urlparse(url)._replace(path=r.headers['Location']).geturl() return url def extract_tb_url_from_html(html_content):