node-fetch/fetch-blob

Move check to the top

jimmywarting opened this issue · 0 comments

fetch-blob/index.js

Lines 178 to 181 in 5ba554e

// don't add the overflow to new blobParts
if (added >= span) {
break;
}

I think there might be some error about slicing blob (or BlobDataItem, aka fileFromPath) that would normally end with a zero size.
have not yet tested it out. I used the same related slice logic elsewhere that resulted in a error

A simple test could be to do:

const blob = fileFromPathSync('./package.json') // or
const blob = new Blob(['hello'])
await blob.slice(0, 0).text()

whether or not it's working as intended i think it would be best if this check was moved to the beginning of the loop

for (const part of parts) { 
  // don't add the overflow to new blobParts 
  if (added >= span) { 
    break; 
  } 
  ...