diff options
Diffstat (limited to 'extensions/fetch/22_body.js')
-rw-r--r-- | extensions/fetch/22_body.js | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/extensions/fetch/22_body.js b/extensions/fetch/22_body.js index 8c93e0fcf..f0c7ac8bd 100644 --- a/extensions/fetch/22_body.js +++ b/extensions/fetch/22_body.js @@ -223,8 +223,6 @@ return Object.defineProperties(prototype.prototype, mixin); } - const decoder = new TextDecoder(); - /** * https://fetch.spec.whatwg.org/#concept-body-package-data * @param {Uint8Array} bytes @@ -263,14 +261,12 @@ throw new TypeError("Missing content type"); } case "JSON": - return JSON.parse(decoder.decode(bytes)); + return JSON.parse(core.decode(bytes)); case "text": - return decoder.decode(bytes); + return core.decode(bytes); } } - const encoder = new TextEncoder(); - /** * @param {BodyInit} object * @returns {{body: InnerBody, contentType: string | null}} @@ -305,10 +301,10 @@ length = res.body.byteLength; contentType = res.contentType; } else if (object instanceof URLSearchParams) { - source = encoder.encode(object.toString()); + source = core.encode(object.toString()); contentType = "application/x-www-form-urlencoded;charset=UTF-8"; } else if (typeof object === "string") { - source = encoder.encode(object); + source = core.encode(object); contentType = "text/plain;charset=UTF-8"; } else if (object instanceof ReadableStream) { stream = object; |