Update alook-redirect
This commit is contained in:
@@ -6,33 +6,10 @@ export default {
|
|||||||
return new Response("缺少 url 参数", { status: 400 });
|
return new Response("缺少 url 参数", { status: 400 });
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const alookUrl = "alook://" + shortUrl.replace("https://", "");
|
||||||
const resp = await fetch(shortUrl, { redirect: "manual" });
|
|
||||||
const location = resp.headers.get("Location") || "";
|
|
||||||
|
|
||||||
let realUrl = null;
|
|
||||||
|
|
||||||
if (location.includes("viglink.com")) {
|
|
||||||
// 直接从原始 location 字符串里截取 u= 的值,不用 URL 解析(避免自动 decode)
|
|
||||||
const match = location.match(/[?&]u=([^&]+)/);
|
|
||||||
if (match) {
|
|
||||||
realUrl = match[1]; // 保持原始编码,不 decode
|
|
||||||
}
|
|
||||||
} else if (location.includes("account.microsoft.com")) {
|
|
||||||
realUrl = location;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!realUrl) {
|
|
||||||
return new Response("无法解析链接:" + location, { status: 500 });
|
|
||||||
}
|
|
||||||
|
|
||||||
const alookUrl = "alook://" + realUrl.replace("https://", "").replace("https%3A%2F%2F", "");
|
|
||||||
return new Response(
|
return new Response(
|
||||||
`<html><body><script>window.location.href=${JSON.stringify(alookUrl)};</script></body></html>`,
|
`<html><body><script>window.location.href=${JSON.stringify(alookUrl)};</script></body></html>`,
|
||||||
{ headers: { "Content-Type": "text/html;charset=utf-8" } }
|
{ headers: { "Content-Type": "text/html;charset=utf-8" } }
|
||||||
);
|
);
|
||||||
} catch (e) {
|
|
||||||
return new Response("错误:" + e.message, { status: 500 });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user