Skip to content

Commit

Permalink
querystring: replace var with let/const
Browse files Browse the repository at this point in the history
PR-URL: #30429
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
Raoul Jaeckel authored and targos committed Dec 1, 2019
1 parent 34b136b commit 8d9080a
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions lib/querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ const unhexTable = [
// A safe fast alternative to decodeURIComponent
function unescapeBuffer(s, decodeSpaces) {
const out = Buffer.allocUnsafe(s.length);
var index = 0;
var outIndex = 0;
var currentChar;
var nextChar;
var hexHigh;
var hexLow;
let index = 0;
let outIndex = 0;
let currentChar;
let nextChar;
let hexHigh;
let hexLow;
const maxLength = s.length - 2;
// Flag to know if some hex chars have been decoded
var hasHex = false;
let hasHex = false;
while (index < s.length) {
currentChar = s.charCodeAt(index);
if (currentChar === 43 /* '+' */ && decodeSpaces) {
Expand Down Expand Up @@ -161,27 +161,27 @@ function stringify(obj, sep, eq, options) {
sep = sep || '&';
eq = eq || '=';

var encode = QueryString.escape;
let encode = QueryString.escape;
if (options && typeof options.encodeURIComponent === 'function') {
encode = options.encodeURIComponent;
}

if (obj !== null && typeof obj === 'object') {
var keys = Object.keys(obj);
var len = keys.length;
var flast = len - 1;
var fields = '';
for (var i = 0; i < len; ++i) {
var k = keys[i];
var v = obj[k];
var ks = encode(stringifyPrimitive(k));
const keys = Object.keys(obj);
const len = keys.length;
const flast = len - 1;
let fields = '';
for (let i = 0; i < len; ++i) {
const k = keys[i];
const v = obj[k];
let ks = encode(stringifyPrimitive(k));
ks += eq;

if (Array.isArray(v)) {
var vlen = v.length;
const vlen = v.length;
if (vlen === 0) continue;
var vlast = vlen - 1;
for (var j = 0; j < vlen; ++j) {
const vlast = vlen - 1;
for (let j = 0; j < vlen; ++j) {
fields += ks;
fields += encode(stringifyPrimitive(v[j]));
if (j < vlast)
Expand All @@ -204,7 +204,7 @@ function charCodes(str) {
if (str.length === 0) return [];
if (str.length === 1) return [str.charCodeAt(0)];
const ret = new Array(str.length);
for (var i = 0; i < str.length; ++i)
for (let i = 0; i < str.length; ++i)
ret[i] = str.charCodeAt(i);
return ret;
}
Expand Down Expand Up @@ -244,7 +244,7 @@ function parse(qs, sep, eq, options) {
const sepLen = sepCodes.length;
const eqLen = eqCodes.length;

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

var decode = QueryString.unescape;
let decode = QueryString.unescape;
if (options && typeof options.decodeURIComponent === 'function') {
decode = options.decodeURIComponent;
}
const customDecode = (decode !== qsUnescape);

var lastPos = 0;
var sepIdx = 0;
var eqIdx = 0;
var key = '';
var value = '';
var keyEncoded = customDecode;
var valEncoded = customDecode;
let lastPos = 0;
let sepIdx = 0;
let eqIdx = 0;
let key = '';
let value = '';
let keyEncoded = customDecode;
let valEncoded = customDecode;
const plusChar = (customDecode ? '%20' : ' ');
var encodeCheck = 0;
for (var i = 0; i < qs.length; ++i) {
let encodeCheck = 0;
for (let i = 0; i < qs.length; ++i) {
const code = qs.charCodeAt(i);

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

0 comments on commit 8d9080a

Please sign in to comment.