Skip to content
Permalink
Browse files

querystring: replace var with let/const

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 MylesBorins committed Nov 12, 2019
1 parent c0d9a54 commit cbb2f81bf1d761eb083461ef599c252a374b2fa6
Showing with 31 additions and 31 deletions.
  1. +31 −31 lib/querystring.js
@@ -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) {
@@ -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)
@@ -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;
}
@@ -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)
@@ -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. '&')

0 comments on commit cbb2f81

Please sign in to comment.
You can’t perform that action at this time.