diff --git a/lib/fetch/util.js b/lib/fetch/util.js index 4d21e2e17b9..c6871e43238 100644 --- a/lib/fetch/util.js +++ b/lib/fetch/util.js @@ -871,13 +871,13 @@ function isomorphicDecode (input) { // 1. To isomorphic decode a byte sequence input, return a string whose code point // length is equal to input’s length and whose code points have the same values // as the values of input’s bytes, in the same order. - let output = '' - for (let i = 0; i < input.length; i++) { - output += String.fromCharCode(input[i]) + // In JavaScript, argument length limited to 65536 + if (input.length > 65536) { + return input.reduce((previous, current) => previous + String.fromCharCode(current), '') } - return output + return String.fromCharCode(...input) } /**