Question about Base64Decode
AJLoveChina opened this issue · 1 comments
AJLoveChina commented
//ignore white space
text = text.replace(/\s/g,"");
//first check for any unexpected input
if(!(/^[a-z0-9\+\/\s]+\={0,2}$/i.test(text)) || text.length % 4 > 0){
throw new Error("Not a base64-encoded string.");
}
// Q :
// if there is no space in the String text.
// Why not change RegExp to [a-z0-9\+\/] instead of [a-z0-9\+\/\s] ?
nzakas commented
It's probably OK to do that.