diff --git a/src/index.ts b/src/index.ts index 59d152c..8e2f6e8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -29,7 +29,7 @@ export const toFile = async ( const blob = await toBlob(file); return new File([blob], name || '', { - type, + type: type || blob.type, }); }; @@ -43,7 +43,10 @@ export const toBlob = async (file: FileType, type?: string): Promise => { return new Blob([file], { type: type || file.type, }); - } else if (typeof file === 'string' && file.startsWith('blob:')) { + } else if ( + typeof file === 'string' && + (file.startsWith('blob:') || validateDataURL(file)) + ) { const res = await fetch(file); return await res.blob(); }