增加兼容低版本内核的页面
This commit is contained in:
@@ -28,6 +28,15 @@ export function decodeCustomBase64(encoded: string): string {
|
||||
const index = ALPHABET_CUSTOM.indexOf(char);
|
||||
translated += index !== -1 ? ALPHABET_STANDARD.charAt(index) : char;
|
||||
}
|
||||
// Strip whitespace / newlines that may be present in API responses.
|
||||
// Chrome 91 atob() is stricter than modern browsers and rejects these.
|
||||
translated = translated.replace(/\s/g, "");
|
||||
// Ensure correct Base64 padding (=). Modern atob() tolerates missing padding,
|
||||
// but Chrome 91 throws "The string to be decoded is not correctly encoded".
|
||||
const padNeeded = (4 - (translated.length % 4)) % 4;
|
||||
if (padNeeded > 0) {
|
||||
translated += "=".repeat(padNeeded);
|
||||
}
|
||||
const decoded = atob(translated);
|
||||
const bytes = new Uint8Array(decoded.length);
|
||||
for (let i = 0; i < decoded.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user