Skip to content

Commit 335f839

Browse files
committed
v6.2.1
1 parent 5ac31b4 commit 335f839

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## **6.2.1**
2+
- [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values
3+
- [Refactor] Be explicit and use `Object.prototype.hasOwnProperty.call`
4+
- [Tests] remove `parallelshell` since it does not reliably report failures
5+
- [Tests] up to `node` `v6.3`, `v5.12`
6+
- [Dev Deps] update `tape`, `eslint`, `@ljharb/eslint-config`, `qs-iconv`
7+
18
## [**6.2.0**](https://github.com/ljharb/qs/issues?milestone=36&state=closed)
29
- [New] pass Buffers to the encoder/decoder directly (#161)
310
- [New] add "encoder" and "decoder" options, for custom param encoding/decoding (#160)
@@ -17,6 +24,9 @@
1724
## [**6.0.0**](https://github.com/ljharb/qs/issues?milestone=31&state=closed)
1825
- [**#124**](https://github.com/ljharb/qs/issues/124) Use ES6 and drop support for node < v4
1926

27+
## **5.2.1**
28+
- [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values
29+
2030
## [**5.2.0**](https://github.com/ljharb/qs/issues?milestone=30&state=closed)
2131
- [**#64**](https://github.com/ljharb/qs/issues/64) Add option to sort object keys in the query string
2232

dist/qs.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ module.exports = {
1414

1515
var Utils = require('./utils');
1616

17+
var has = Object.prototype.hasOwnProperty;
18+
1719
var defaults = {
1820
delimiter: '&',
1921
depth: 5,
@@ -34,21 +36,18 @@ var parseValues = function parseValues(str, options) {
3436
var part = parts[i];
3537
var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
3638

39+
var key, val;
3740
if (pos === -1) {
38-
obj[options.decoder(part)] = '';
39-
40-
if (options.strictNullHandling) {
41-
obj[options.decoder(part)] = null;
42-
}
41+
key = options.decoder(part);
42+
val = options.strictNullHandling ? null : '';
4343
} else {
44-
var key = options.decoder(part.slice(0, pos));
45-
var val = options.decoder(part.slice(pos + 1));
46-
47-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
48-
obj[key] = [].concat(obj[key]).concat(val);
49-
} else {
50-
obj[key] = val;
51-
}
44+
key = options.decoder(part.slice(0, pos));
45+
val = options.decoder(part.slice(pos + 1));
46+
}
47+
if (has.call(obj, key)) {
48+
obj[key] = [].concat(obj[key]).concat(val);
49+
} else {
50+
obj[key] = val;
5251
}
5352
}
5453

@@ -110,7 +109,7 @@ var parseKeys = function parseKeys(givenKey, val, options) {
110109
if (segment[1]) {
111110
// If we aren't using plain objects, optionally prefix keys
112111
// that would overwrite object prototype properties
113-
if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1])) {
112+
if (!options.plainObjects && has.call(Object.prototype, segment[1])) {
114113
if (!options.allowPrototypes) {
115114
return;
116115
}
@@ -124,7 +123,7 @@ var parseKeys = function parseKeys(givenKey, val, options) {
124123
var i = 0;
125124
while ((segment = child.exec(key)) !== null && i < options.depth) {
126125
i += 1;
127-
if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) {
126+
if (!options.plainObjects && has.call(Object.prototype, segment[1].replace(/\[|\]/g, ''))) {
128127
if (!options.allowPrototypes) {
129128
continue;
130129
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "qs",
33
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
44
"homepage": "https://github.com/ljharb/qs",
5-
"version": "6.2.0",
5+
"version": "6.2.1",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/ljharb/qs.git"

0 commit comments

Comments
 (0)