Reduced variable scopes
parent
53bf52c989
commit
83c145c2ac
|
@ -31,18 +31,18 @@ class DechunkHTTP extends Operation {
|
|||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
var chunks = [];
|
||||
var chunkSizeEnd = input.indexOf("\n") + 1;
|
||||
var lineEndings = input.charAt(chunkSizeEnd - 2) == "\r" ? "\r\n" : "\n";
|
||||
var lineEndingsLength = lineEndings.length;
|
||||
var chunkSize = parseInt(input.slice(0, chunkSizeEnd), 16);
|
||||
let chunks = [];
|
||||
let chunkSizeEnd = input.indexOf("\n") + 1;
|
||||
let lineEndings = input.charAt(chunkSizeEnd - 2) === "\r" ? "\r\n" : "\n";
|
||||
let lineEndingsLength = lineEndings.length;
|
||||
let chunkSize = parseInt(input.slice(0, chunkSizeEnd), 16);
|
||||
while (!isNaN(chunkSize)) {
|
||||
chunks.push(input.slice(chunkSizeEnd, chunkSize + chunkSizeEnd));
|
||||
input = input.slice(chunkSizeEnd + chunkSize + lineEndingsLength);
|
||||
chunkSizeEnd = input.indexOf(lineEndings) + lineEndingsLength;
|
||||
chunkSize = parseInt(input.slice(0, chunkSizeEnd), 16);
|
||||
}
|
||||
return chunks.join('') + input;
|
||||
return chunks.join("") + input;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue