misc_pterodactyl-panel/resources/scripts/lib/base64.ts
2022-10-31 12:18:25 -06:00

16 lines
406 B
TypeScript

function decodeBase64 (input: string): string {
input = input.replace(/-/g, '+').replace(/_/g, '/');
const pad = input.length % 4;
if (pad) {
if (pad === 1) {
throw new Error('InvalidLengthError: Input base64url string is the wrong length to determine padding');
}
input += new Array(5 - pad).join('=');
}
return input;
}
export { decodeBase64 }