fix base64 preprocessing

This commit is contained in:
or-else
2019-11-12 15:53:52 +03:00
parent 4c28753e6a
commit 8ee50adf4d
+2 -2
View File
@@ -207,11 +207,11 @@ export function base64DecodedLen(n) {
// The string may be base64-URL encoded without the padding.
export function base64ReEncode(str) {
if (str) {
str = str.replace('-', '+').replace('_', '/');
str = str.replace(/-/g, '+').replace(/_/g, '/');
try {
str = btoa(atob(str));
} catch(err) {
console.log("Failed to base64 re-encode string");
console.log("Failed to base64 re-encode string.", err);
str = null;
}
}