Skip to content

Instantly share code, notes, and snippets.

@ikasoba
Created June 29, 2022 09:47
Show Gist options
  • Save ikasoba/ab2bac6238aba4b3d4fb3bd17bcd63c8 to your computer and use it in GitHub Desktop.
Save ikasoba/ab2bac6238aba4b3d4fb3bd17bcd63c8 to your computer and use it in GitHub Desktop.
function isBase64(value){
if (value == "")return false;
for (let i = 0; i<value.length; ){
const x = value.slice(i,i+=4);
if (i==value.length-1 && !x.match(/^[a-zA-Z0-9]+={0,4}$/))return false;
if (i<value.length-1 && !x.match(/^[a-zA-Z0-9]+$/))return false;
if (x.length != 4)return false;
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment