I\'m using the window.atob(\'string\') function to decode a string from base64 to a string. Now I wonder, is there any way to check that \'string\' is actually
window.atob(\'string\')
This should do the trick.
function isBase64(str) { if (str ==='' || str.trim() ===''){ return false; } try { return btoa(atob(str)) == str; } catch (err) { return false; } }