Fix room turnover token parsing

This commit is contained in:
170-carry 2026-04-28 00:13:21 +08:00
parent 3629d44829
commit 84c48d0523

View File

@ -489,7 +489,7 @@
const DEFAULT_API_BASE = "https://jvapi.haiyihy.com/";
const DEFAULT_API_PREFIX = "/go";
const DEFAULT_AVATAR = "../../assets/defaultAvatar-CdxWBK1k.png";
const query = new URLSearchParams(window.location.search);
const query = buildPageQueryParams();
const resolvedAPIBase = resolveAPIBase();
const fallbackLevels = Array.from({ length: 7 }, (_, index) => ({
level: index + 1,
@ -525,6 +525,21 @@
return value == null ? "" : String(value).trim();
}
function buildPageQueryParams() {
const params = new URLSearchParams(window.location.search);
const hash = window.location.hash || "";
const queryIndex = hash.indexOf("?");
if (queryIndex >= 0) {
const hashParams = new URLSearchParams(hash.slice(queryIndex + 1));
hashParams.forEach((value, key) => {
if (!params.has(key)) {
params.append(key, value);
}
});
}
return params;
}
function textFromQuery(keys, fallback) {
for (const key of keys) {
const value = trimValue(query.get(key));
@ -536,7 +551,11 @@
}
function resolveToken() {
return textFromQuery(["token", "accessToken", "authorization"], "");
const token = textFromQuery(["token", "accessToken", "authorization"], "");
if (token.toLowerCase().startsWith("bearer ")) {
return "Bearer " + token.slice(7).replace(/ /g, "+");
}
return token.replace(/ /g, "+");
}
function numberFromQuery(keys, fallback) {