Skip to content

Commit 545d7c8

Browse files
cyfung1031CodFrm
authored andcommitted
🐛 修正 finalUrl缺失域名 (#656)
1 parent 3334b0c commit 545d7c8

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
@@ -1199,7 +1199,18 @@ export default class GMApi {
11991199
details.responseHeaders?.forEach((header) => {
12001200
if (header.name.toLowerCase() === "location") {
12011201
// 重定向
1202-
location = header.value || "";
1202+
if (header.value) {
1203+
try {
1204+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Location
1205+
// <url> May be relative to the request URL or an absolute URL.
1206+
const url = new URL(header.value, details.url);
1207+
if (url.href) {
1208+
location = url.href;
1209+
}
1210+
} catch {
1211+
// ignore
1212+
}
1213+
}
12031214
}
12041215
});
12051216
if (location) {

0 commit comments

Comments
 (0)