Skip to content

Commit

Permalink
Avoid Array#splice
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Jul 27, 2018
1 parent 228956b commit 4e65517
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var parseValues = function parseQueryStringValues(str, options) {
var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
var parts = cleanStr.split(options.delimiter, limit);
var charset = options.charset;
var skipIndex = -1; // Keep track of where the utf8 sentinel was found
var i;

if (options.utf8Sentinel) {
Expand All @@ -52,13 +53,16 @@ var parseValues = function parseQueryStringValues(str, options) {
} else if (parts[i] === isoSentinel) {
charset = 'iso-8859-1';
}
parts.splice(i, 1);
skipIndex = i;
i = parts.length; // The eslint settings do not allow break;
}
}
}

for (i = 0; i < parts.length; ++i) {
if (i === skipIndex) {
continue;
}
var part = parts[i];

var bracketEqualsPos = part.indexOf(']=');
Expand Down

0 comments on commit 4e65517

Please sign in to comment.