Skip to content

Commit

Permalink
[Dev Deps] backport from main
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jan 10, 2022
1 parent 5f8e28b commit f047c9d
Show file tree
Hide file tree
Showing 16 changed files with 280 additions and 146 deletions.
45 changes: 45 additions & 0 deletions .editorconfig
@@ -0,0 +1,45 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 160
quote_type = single

[test/*]
max_line_length = off

[*.md]
indent_size = off
max_line_length = off

[*.json]
max_line_length = off

[Makefile]
max_line_length = off

[CHANGELOG.md]
indent_style = space
indent_size = 2

[LICENSE]
indent_size = 2
max_line_length = off

[coverage/**/*]
indent_size = off
indent_style = off
indent = off
max_line_length = off

[dist/*]
max_line_length = off
insert_final_newline = off

[.nycrc]
indent_style = off
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

32 changes: 24 additions & 8 deletions .eslintrc
Expand Up @@ -3,21 +3,37 @@

"extends": "@ljharb",

"ignorePatterns": [
"dist/",
],

"rules": {
"complexity": [2, 25],
"consistent-return": [1],
"complexity": [2, 29],
"consistent-return": 1,
"func-name-matching": 0,
"id-length": [2, { "min": 1, "max": 25, "properties": "never" }],
"indent": [2, 4],
"max-len": 0,
"max-lines-per-function": 0,
"max-params": [2, 9],
"max-statements": [0, 36],
"no-extra-parens": [1],
"no-continue": [1],
"max-lines": 0,
"max-params": [2, 12],
"max-statements": [2, 45],
"multiline-comment-style": 0,
"no-continue": 1,
"no-magic-numbers": 0,
"no-param-reassign": 1,
"no-restricted-syntax": [2, "BreakStatement", "DebuggerStatement", "ForInStatement", "LabeledStatement", "WithStatement"],
"operator-linebreak": 1,
"sort-keys": 0,
},

"overrides": [
{
"files": "test/**",
"rules": {
"max-lines-per-function": 0,
"max-statements": 0,
"no-extend-native": 0,
"function-paren-newline": 0,
},
},
],
}
8 changes: 8 additions & 0 deletions .gitignore
Expand Up @@ -18,3 +18,11 @@ lib-cov
complexity.md
tests.tap
dist/*

# Only apps should have lockfiles
yarn.lock
package-lock.json
npm-shrinkwrap.json

.nyc_output/
coverage/
18 changes: 14 additions & 4 deletions .npmignore
@@ -1,4 +1,14 @@
bower.json
component.json
.npmignore
.travis.yml
# gitignore
npm-debug.log
node_modules
.DS_Store

# Only apps should have lockfiles
yarn.lock
package-lock.json
npm-shrinkwrap.json

.nyc_output/
coverage/

.github/workflows
13 changes: 13 additions & 0 deletions .nycrc
@@ -0,0 +1,13 @@
{
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"lines": 86,
"statements": 85.93,
"functions": 82.43,
"branches": 76.06,
"exclude": [
"coverage",
"dist"
]
}
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -380,7 +380,7 @@ assert.equal(nullsSkipped, 'a=b');

### Dealing with special character sets

By default the encoding and decoding of characters is done in `utf-8`. If you
By default the encoding and decoding of characters is done in `utf-8`. If you
wish to encode querystrings to a different character set (i.e.
[Shift JIS](https://en.wikipedia.org/wiki/Shift_JIS)) you can use the
[`qs-iconv`](https://github.com/martinheidegger/qs-iconv) library:
Expand Down
38 changes: 19 additions & 19 deletions bower.json
@@ -1,21 +1,21 @@
{
"name": "qs",
"main": "dist/qs.js",
"homepage": "https://github.com/hapijs/qs",
"authors": [
"Nathan LaFreniere <quitlahok@gmail.com>"
],
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
"keywords": [
"querystring",
"qs"
],
"license": "BSD-3-Clause",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
"name": "qs",
"main": "dist/qs.js",
"homepage": "https://github.com/hapijs/qs",
"authors": [
"Nathan LaFreniere <quitlahok@gmail.com>"
],
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
"keywords": [
"querystring",
"qs"
],
"license": "BSD-3-Clause",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
26 changes: 13 additions & 13 deletions component.json
@@ -1,15 +1,15 @@
{
"name": "qs",
"repository": "hapijs/qs",
"description": "query-string parser / stringifier with nesting support",
"version": "6.2.3",
"keywords": ["querystring", "query", "parser"],
"main": "lib/index.js",
"scripts": [
"lib/index.js",
"lib/parse.js",
"lib/stringify.js",
"lib/utils.js"
],
"license": "BSD-3-Clause"
"name": "qs",
"repository": "hapijs/qs",
"description": "query-string parser / stringifier with nesting support",
"version": "6.2.3",
"keywords": ["querystring", "query", "parser"],
"main": "lib/index.js",
"scripts": [
"lib/index.js",
"lib/parse.js",
"lib/stringify.js",
"lib/utils.js"
],
"license": "BSD-3-Clause"
}
15 changes: 6 additions & 9 deletions lib/parse.js
Expand Up @@ -60,11 +60,11 @@ var parseObject = function parseObject(chain, val, options) {
if (!options.parseArrays && cleanRoot === '') {
obj = { 0: val };
} else if (
!isNaN(index) &&
root !== cleanRoot &&
String(index) === cleanRoot &&
index >= 0 &&
(options.parseArrays && index <= options.arrayLimit)
!isNaN(index)
&& root !== cleanRoot
&& String(index) === cleanRoot
&& index >= 0
&& (options.parseArrays && index <= options.arrayLimit)
) {
obj = [];
obj[index] = parseObject(chain, val, options);
Expand Down Expand Up @@ -98,10 +98,7 @@ var parseKeys = function parseKeys(givenKey, val, options) {

var keys = [];
if (parent) {
/*
* If we aren't using plain objects, optionally prefix keys
* that would overwrite object prototype properties
*/
// If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
if (!options.plainObjects && has.call(Object.prototype, parent)) {
if (!options.allowPrototypes) {
return;
Expand Down
49 changes: 44 additions & 5 deletions lib/stringify.js
Expand Up @@ -23,8 +23,17 @@ var defaults = {
};

var isArray = Array.isArray;

var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots) {
var stringify = function stringify(
object,
prefix,
generateArrayPrefix,
strictNullHandling,
skipNulls,
encoder,
filter,
sort,
allowDots
) {
var obj = object;
if (typeof filter === 'function') {
obj = filter(prefix, obj);
Expand Down Expand Up @@ -67,9 +76,29 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
}

if (isArray(obj)) {
values = values.concat(stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots));
values = values.concat(stringify(
obj[key],
generateArrayPrefix(prefix, key),
generateArrayPrefix,
strictNullHandling,
skipNulls,
encoder,
filter,
sort,
allowDots
));
} else {
values = values.concat(stringify(obj[key], prefix + (allowDots ? '.' + key : '[' + key + ']'), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots));
values = values.concat(stringify(
obj[key],
prefix + (allowDots ? '.' + key : '[' + key + ']'),
generateArrayPrefix,
strictNullHandling,
skipNulls,
encoder,
filter,
sort,
allowDots
));
}
}

Expand Down Expand Up @@ -133,7 +162,17 @@ module.exports = function (object, opts) {
continue;
}

keys = keys.concat(stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots));
keys = keys.concat(stringify(
obj[key],
key,
generateArrayPrefix,
strictNullHandling,
skipNulls,
encoder,
filter,
sort,
allowDots
));
}

return keys.join(delimiter);
Expand Down
20 changes: 12 additions & 8 deletions lib/utils.js
Expand Up @@ -114,13 +114,13 @@ exports.encode = function (str) {
var c = string.charCodeAt(i);

if (
c === 0x2D || // -
c === 0x2E || // .
c === 0x5F || // _
c === 0x7E || // ~
(c >= 0x30 && c <= 0x39) || // 0-9
(c >= 0x41 && c <= 0x5A) || // a-z
(c >= 0x61 && c <= 0x7A) // A-Z
c === 0x2D // -
|| c === 0x2E // .
|| c === 0x5F // _
|| c === 0x7E // ~
|| (c >= 0x30 && c <= 0x39) // 0-9
|| (c >= 0x41 && c <= 0x5A) // a-z
|| (c >= 0x61 && c <= 0x7A) // A-Z
) {
out += string.charAt(i);
continue;
Expand All @@ -143,7 +143,11 @@ exports.encode = function (str) {

i += 1;
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)];
/* eslint operator-linebreak: [2, "before"] */
out += hexTable[0xF0 | (c >> 18)]
+ hexTable[0x80 | ((c >> 12) & 0x3F)]
+ hexTable[0x80 | ((c >> 6) & 0x3F)]
+ hexTable[0x80 | (c & 0x3F)];
}

return out;
Expand Down

0 comments on commit f047c9d

Please sign in to comment.