Fix window.btoa call in browser (#7814)

This commit is contained in:
Robin Munn
2023-10-26 09:05:59 +01:00
committed by GitHub
parent 23a576b8bd
commit 801e8e312c
+2 -2
View File
@@ -823,8 +823,8 @@ exports.hashString = function(str) {
Base64 utility functions that work in either browser or Node.js Base64 utility functions that work in either browser or Node.js
*/ */
if(typeof window !== 'undefined') { if(typeof window !== 'undefined') {
exports.btoa = window.btoa; exports.btoa = function(binstr) { return window.btoa(binstr); }
exports.atob = window.atob; exports.atob = function(b64) { return window.atob(b64); }
} else { } else {
exports.btoa = function(binstr) { exports.btoa = function(binstr) {
return Buffer.from(binstr, 'binary').toString('base64'); return Buffer.from(binstr, 'binary').toString('base64');