diff options
Diffstat (limited to 'extensions/fetch/22_body.js')
-rw-r--r-- | extensions/fetch/22_body.js | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/extensions/fetch/22_body.js b/extensions/fetch/22_body.js index 2a1a91159..97ed57c8b 100644 --- a/extensions/fetch/22_body.js +++ b/extensions/fetch/22_body.js @@ -286,27 +286,25 @@ }); case "FormData": { if (mimeType !== null) { - if (mimeType !== null) { - const essence = mimesniff.essence(mimeType); - if (essence === "multipart/form-data") { - const boundary = mimeType.parameters.get("boundary"); - if (boundary === null) { - throw new TypeError( - "Missing boundary parameter in mime type of multipart formdata.", - ); - } - return parseFormData(bytes, boundary); - } else if (essence === "application/x-www-form-urlencoded") { - const entries = parseUrlEncoded(bytes); - return formDataFromEntries( - ArrayPrototypeMap( - entries, - (x) => ({ name: x[0], value: x[1] }), - ), + const essence = mimesniff.essence(mimeType); + if (essence === "multipart/form-data") { + const boundary = mimeType.parameters.get("boundary"); + if (boundary === null) { + throw new TypeError( + "Missing boundary parameter in mime type of multipart formdata.", ); } + return parseFormData(bytes, boundary); + } else if (essence === "application/x-www-form-urlencoded") { + const entries = parseUrlEncoded(bytes); + return formDataFromEntries( + ArrayPrototypeMap( + entries, + (x) => ({ name: x[0], value: x[1] }), + ), + ); } - throw new TypeError("Invalid form data"); + throw new TypeError("Body can not be decoded as form data"); } throw new TypeError("Missing content type"); } |