Created
June 16, 2017 14:53
-
-
Save RyanNutt/fe1836843a4257a4a362b2f551213835 to your computer and use it in GitHub Desktop.
Check if a String is base64 encoded using JavaScript - from https://stackoverflow.com/a/34068497/1561431
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isBase64(str) { | |
try { | |
return btoa(atob(str)) == str; | |
} catch (err) { | |
return false; | |
} | |
} |
This doesn't work on Node.js env.
This doesn't work on Node.js env.
you probably didn't install atob and btoa npm packages
if test XXXL or 75ml or sth, is doesn't work
Any string of 4 characters, consisting of letters and numbers, can pass the check.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!