dy / string-to-arraybuffer

Convert plain/base64/datauri string to ArrayBuffer
10 stars 1 forks source link

Throw on large string #2

Open ErnestBrandi opened 3 years ago

ErnestBrandi commented 3 years ago

Hi, it throws on line 17 with large input strings

if (isBase64(arg)) arg = atob(arg)

I think you can just replace this with

try {
    arg = atob(arg)
} catch(err) {}

it will throw (and be catched) if it is not a base64 string.