1
0

fix: ๐Ÿ› update decodePayload

This commit is contained in:
kira924age
2023-12-21 21:17:53 +09:00
committed by Toby
parent 1f511549f5
commit f8a216574a

View File

@@ -199,8 +199,8 @@ async function importKey(key: string | JsonWebKey, algorithm: SubtleCryptoImport
function decodePayload<T = any>(raw: string): T | undefined {
try {
const binaryString = atob(raw)
const encodedString = encodeURIComponent(binaryString).replace(/%([0-9A-F]{2})/g, (match, p1) => {
return String.fromCharCode('0x' + p1);
const encodedString = encodeURIComponent(binaryString).replace(/%([0-9A-F]{2})/g, (_match, p1) => {
return String.fromCharCode(parseInt(p1, 16));
});
return JSON.parse(decodeURIComponent(encodedString));