Skip to content

Commit

Permalink
Fix unsupported BodyInit type (sindresorhus#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
edram committed Apr 25, 2024
1 parent 44f97b6 commit 5eaa1e2
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions source/core/constants.ts
Expand Up @@ -9,15 +9,19 @@ export const supportsRequestStreams = (() => {
const supportsRequest = typeof globalThis.Request === 'function';

if (supportsReadableStream && supportsRequest) {
hasContentType = new globalThis.Request('https://empty.invalid', {
body: new globalThis.ReadableStream(),
method: 'POST',
// @ts-expect-error - Types are outdated.
get duplex() {
duplexAccessed = true;
return 'half';
},
}).headers.has('Content-Type');
try {
hasContentType = new globalThis.Request('https://empty.invalid', {
body: new globalThis.ReadableStream(),
method: 'POST',
// @ts-expect-error - Types are outdated.
get duplex() {
duplexAccessed = true;
return 'half';
},
}).headers.has('Content-Type');
} catch {
// IOS QQBrowser throw "unsupported BodyInit type" Error
}
}

return duplexAccessed && !hasContentType;
Expand Down

0 comments on commit 5eaa1e2

Please sign in to comment.