Commit 150a052d authored by Chunchi Che's avatar Chunchi Che

Merge branch 'fix/match' into 'main'

修复中文用户名娱乐匹配失败的问题

See merge request mycard/Neos!312
parents e52bde55 b90127c5
......@@ -12,8 +12,7 @@ export async function match(
arena: string = "entertain",
): Promise<MatchInfo | undefined> {
const headers = {
Authorization:
"Basic " + btoa(encodeURIComponent(username) + ":" + extraId),
Authorization: "Basic " + customBase64Encode(username + ":" + extraId),
};
let response: Response | undefined = undefined;
const params = new URLSearchParams({
......@@ -38,3 +37,9 @@ export async function match(
return (await response?.json()) as MatchInfo;
}
function customBase64Encode(input: string): string {
const uint8Array = new TextEncoder().encode(input);
const base64String = btoa(String.fromCharCode(...uint8Array));
return base64String;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment