Use codePointAt/fromCodePoint instead of charCodeAt/fromCharCode (S7758)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 00:31:21 +08:00
parent 1c8ac09184
commit 94e200bded

View File

@@ -13,7 +13,7 @@ export function encodeReturnTo(returnToPath) {
const bytes = new TextEncoder().encode(returnToPath);
let binary = "";
bytes.forEach((byte) => {
binary += String.fromCharCode(byte);
binary += String.fromCodePoint(byte);
});
return btoa(binary);
}
@@ -25,6 +25,6 @@ export function encodeReturnTo(returnToPath) {
*/
export function decodeReturnTo(encodedReturnTo) {
const binary = atob(encodedReturnTo);
const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
const bytes = Uint8Array.from(binary, (char) => char.codePointAt(0));
return new TextDecoder().decode(bytes);
}