fix(pugongying): 修复小红书短链接解析失败的问题

xhslink.com 短链接对 HEAD 请求返回 404,且重定向 URL 在 HTML body
的 href 中而非 HTTP 302 header。改用 GET 请求并从响应体中解析真实 URL。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
wxs 2026-03-13 23:52:26 +08:00
parent 99d16f1f70
commit e494f32b14

View File

@ -243,10 +243,19 @@
return;
}
GM_xmlhttpRequest({
method: "HEAD",
method: "GET",
url,
onload(res) {
resolve(res.finalUrl || url);
if (res.finalUrl && res.finalUrl !== url) {
resolve(res.finalUrl);
return;
}
const match = res.responseText && res.responseText.match(/href="([^"]+)"/);
if (match) {
resolve(match[1].replace(/&amp;/g, "&"));
} else {
resolve(url);
}
},
onerror() {
resolve(url);