Skip to content

Commit 3ed018a

Browse files
authored
🐛 修正 finalUrl缺失域名 (#656)
1 parent 4b1a5de commit 3ed018a

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/app/service/service_worker/gm_api.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,18 @@ export default class GMApi {
11921192
details.responseHeaders?.forEach((header) => {
11931193
if (header.name.toLowerCase() === "location") {
11941194
// 重定向
1195-
location = header.value || "";
1195+
if (header.value) {
1196+
try {
1197+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Location
1198+
// <url> May be relative to the request URL or an absolute URL.
1199+
const url = new URL(header.value, details.url);
1200+
if (url.href) {
1201+
location = url.href;
1202+
}
1203+
} catch {
1204+
// ignore
1205+
}
1206+
}
11961207
}
11971208
});
11981209
if (location) {

0 commit comments

Comments
 (0)