-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
the default type argument for blob.slice should be empty string #37352
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Looking at it some more i see that you validate the input arguments a bit here and there new buffer.Blob(['abc']).slice('2') // ERR_INVALID_ARG_TYPE
new window.Blob(['abc']).slice('2').text() // c new buffer.Blob([], {type: {}}).type // ERR_INVALID_ARG_TYPE
new window.Blob([], {type: {}}).type // "[object object]" You should just cast the type into a string whatever it is. Just a word of caution about lowerCasing the type, should probably not do it since we loose information This is quite funny: new buffer.Blob([], { type: new String('hey') })
// TypeError [ERR_INVALID_ARG_TYPE]: The "options.type" property must be of type string.
// Received an instance of String new buffer.Blob(['abc']).slice(new Number(2))
// TypeError [ERR_INVALID_ARG_TYPE]: The "start" argument must be of type number.
// Received an instance of Number Edit: LoL javascript... |
everything source in the blob constructor that is not understood should be casted into a string await new window.Blob([ function() { return } ]).text() === "function() { return }"
await new buffer.Blob([ function() { return } ]) // [ERR_INVALID_ARG_TYPE]: The "source" argument must be of type ... |
PR-URL: nodejs#37361 Fixes: nodejs#37352 Fixes: nodejs#37356 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#37361 Fixes: nodejs#37352 Fixes: nodejs#37356 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#37361 Fixes: nodejs#37352 Fixes: nodejs#37356 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#37361 Backport-PR-URL: nodejs#39704 Fixes: nodejs#37352 Fixes: nodejs#37356 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
I took a peek at
buffer.Blob.toString()
and saw that thetype
argument was defaulted to itselfnode/lib/internal/blob.js
Line 179 in 17467d1
that is not the case in the browser (it's not what we are doing in fetch-blob) and the spec says it should default the type to a empty string if it's not provided
What is the expected behavior?
What do you see instead?
The text was updated successfully, but these errors were encountered: