[firestore][js] additional Blob class input arg validations

This commit is contained in:
Salakar 2018-05-03 21:50:53 +01:00
parent 86a8385f2a
commit d493e00a67
1 changed files with 6 additions and 0 deletions

View File

@ -14,6 +14,12 @@ export default class Blob {
* @param base64 string
*/
static fromBase64String(base64: string): Blob {
if (typeof base64 !== 'string' || base64.length < 1) {
throw new Error(
'firestore.Blob.fromBase64String expects a string of at least 1 character in length'
);
}
return new Blob(Base64.atob(base64));
}