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 2c103b6 commit da1eee0
Show file tree
Hide file tree
Showing 15 changed files with 215 additions and 129 deletions.
44 changes: 44 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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

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

This file was deleted.

30 changes: 24 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,35 @@

"extends": "@ljharb",

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

"rules": {
"complexity": [2, 25],
"complexity": [2, 29],
"consistent-return": 1,
"func-name-matching": 0,
"id-length": [2, { "min": 1, "max": 25, "properties": "never" }],
"indent": [2, 4],
"max-params": [2, 11],
"max-statements": [2, 42],
"no-extra-parens": 1,
"max-lines-per-function": 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
}
},

"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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,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
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"name": "qs",
"main": "dist/qs.js",
"homepage": "https://github.com/hapijs/qs",
"authors": [
"Nathan LaFreniere <[email protected]>"
],
"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 <[email protected]>"
],
"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
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "qs",
"repository": "hapijs/qs",
"description": "query-string parser / stringifier with nesting support",
"version": "6.3.2",
"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.3.2",
"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
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ var parseObject = function parseObjectRecursive(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 parseQueryStringKeys(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
14 changes: 7 additions & 7 deletions lib/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ var utils = require('./utils');
var formats = require('./formats');

var arrayPrefixGenerators = {
brackets: function brackets(prefix) { // eslint-disable-line func-name-matching
brackets: function brackets(prefix) {
return prefix + '[]';
},
indices: function indices(prefix, key) { // eslint-disable-line func-name-matching
indices: function indices(prefix, key) {
return prefix + '[' + key + ']';
},
repeat: function repeat(prefix) { // eslint-disable-line func-name-matching
repeat: function repeat(prefix) {
return prefix;
}
};
Expand All @@ -27,14 +27,14 @@ var defaults = {
delimiter: '&',
encode: true,
encoder: utils.encode,
serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching
serializeDate: function serializeDate(date) {
return toISO.call(date);
},
skipNulls: false,
strictNullHandling: false
};

var stringify = function stringify( // eslint-disable-line func-name-matching
var stringify = function stringify(
object,
prefix,
generateArrayPrefix,
Expand Down Expand Up @@ -136,12 +136,12 @@ module.exports = function (object, opts) {
var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls;
var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode;
var encoder = encode ? (typeof options.encoder === 'function' ? options.encoder : defaults.encoder) : null;
var encoder = encode ? typeof options.encoder === 'function' ? options.encoder : defaults.encoder : null;
var sort = typeof options.sort === 'function' ? options.sort : null;
var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots;
var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate;
if (typeof options.format === 'undefined') {
options.format = formats.default;
options.format = formats['default'];
} else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) {
throw new TypeError('Unknown format option provided.');
}
Expand Down
20 changes: 12 additions & 8 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,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 @@ -128,7 +128,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-disable-line max-len
/* 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
Loading

0 comments on commit da1eee0

Please sign in to comment.