Skip to content

Commit 8d9080a

Browse files
Raoul Jaeckeltargos
Raoul Jaeckel
authored andcommitted
querystring: replace var with let/const
PR-URL: #30429 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 34b136b commit 8d9080a

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

lib/querystring.js

+31-31
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ const unhexTable = [
6767
// A safe fast alternative to decodeURIComponent
6868
function unescapeBuffer(s, decodeSpaces) {
6969
const out = Buffer.allocUnsafe(s.length);
70-
var index = 0;
71-
var outIndex = 0;
72-
var currentChar;
73-
var nextChar;
74-
var hexHigh;
75-
var hexLow;
70+
let index = 0;
71+
let outIndex = 0;
72+
let currentChar;
73+
let nextChar;
74+
let hexHigh;
75+
let hexLow;
7676
const maxLength = s.length - 2;
7777
// Flag to know if some hex chars have been decoded
78-
var hasHex = false;
78+
let hasHex = false;
7979
while (index < s.length) {
8080
currentChar = s.charCodeAt(index);
8181
if (currentChar === 43 /* '+' */ && decodeSpaces) {
@@ -161,27 +161,27 @@ function stringify(obj, sep, eq, options) {
161161
sep = sep || '&';
162162
eq = eq || '=';
163163

164-
var encode = QueryString.escape;
164+
let encode = QueryString.escape;
165165
if (options && typeof options.encodeURIComponent === 'function') {
166166
encode = options.encodeURIComponent;
167167
}
168168

169169
if (obj !== null && typeof obj === 'object') {
170-
var keys = Object.keys(obj);
171-
var len = keys.length;
172-
var flast = len - 1;
173-
var fields = '';
174-
for (var i = 0; i < len; ++i) {
175-
var k = keys[i];
176-
var v = obj[k];
177-
var ks = encode(stringifyPrimitive(k));
170+
const keys = Object.keys(obj);
171+
const len = keys.length;
172+
const flast = len - 1;
173+
let fields = '';
174+
for (let i = 0; i < len; ++i) {
175+
const k = keys[i];
176+
const v = obj[k];
177+
let ks = encode(stringifyPrimitive(k));
178178
ks += eq;
179179

180180
if (Array.isArray(v)) {
181-
var vlen = v.length;
181+
const vlen = v.length;
182182
if (vlen === 0) continue;
183-
var vlast = vlen - 1;
184-
for (var j = 0; j < vlen; ++j) {
183+
const vlast = vlen - 1;
184+
for (let j = 0; j < vlen; ++j) {
185185
fields += ks;
186186
fields += encode(stringifyPrimitive(v[j]));
187187
if (j < vlast)
@@ -204,7 +204,7 @@ function charCodes(str) {
204204
if (str.length === 0) return [];
205205
if (str.length === 1) return [str.charCodeAt(0)];
206206
const ret = new Array(str.length);
207-
for (var i = 0; i < str.length; ++i)
207+
for (let i = 0; i < str.length; ++i)
208208
ret[i] = str.charCodeAt(i);
209209
return ret;
210210
}
@@ -244,7 +244,7 @@ function parse(qs, sep, eq, options) {
244244
const sepLen = sepCodes.length;
245245
const eqLen = eqCodes.length;
246246

247-
var pairs = 1000;
247+
let pairs = 1000;
248248
if (options && typeof options.maxKeys === 'number') {
249249
// -1 is used in place of a value like Infinity for meaning
250250
// "unlimited pairs" because of additional checks V8 (at least as of v5.4)
@@ -255,22 +255,22 @@ function parse(qs, sep, eq, options) {
255255
pairs = (options.maxKeys > 0 ? options.maxKeys : -1);
256256
}
257257

258-
var decode = QueryString.unescape;
258+
let decode = QueryString.unescape;
259259
if (options && typeof options.decodeURIComponent === 'function') {
260260
decode = options.decodeURIComponent;
261261
}
262262
const customDecode = (decode !== qsUnescape);
263263

264-
var lastPos = 0;
265-
var sepIdx = 0;
266-
var eqIdx = 0;
267-
var key = '';
268-
var value = '';
269-
var keyEncoded = customDecode;
270-
var valEncoded = customDecode;
264+
let lastPos = 0;
265+
let sepIdx = 0;
266+
let eqIdx = 0;
267+
let key = '';
268+
let value = '';
269+
let keyEncoded = customDecode;
270+
let valEncoded = customDecode;
271271
const plusChar = (customDecode ? '%20' : ' ');
272-
var encodeCheck = 0;
273-
for (var i = 0; i < qs.length; ++i) {
272+
let encodeCheck = 0;
273+
for (let i = 0; i < qs.length; ++i) {
274274
const code = qs.charCodeAt(i);
275275

276276
// Try matching key/value pair separator (e.g. '&')

0 commit comments

Comments
 (0)