Skip to content

Commit

Permalink
v6.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 20, 2016
1 parent 5ac31b4 commit 335f839
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## **6.2.1**
- [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values
- [Refactor] Be explicit and use `Object.prototype.hasOwnProperty.call`
- [Tests] remove `parallelshell` since it does not reliably report failures
- [Tests] up to `node` `v6.3`, `v5.12`
- [Dev Deps] update `tape`, `eslint`, `@ljharb/eslint-config`, `qs-iconv`

## [**6.2.0**](https://github.com/ljharb/qs/issues?milestone=36&state=closed)
- [New] pass Buffers to the encoder/decoder directly (#161)
- [New] add "encoder" and "decoder" options, for custom param encoding/decoding (#160)
Expand All @@ -17,6 +24,9 @@
## [**6.0.0**](https://github.com/ljharb/qs/issues?milestone=31&state=closed)
- [**#124**](https://github.com/ljharb/qs/issues/124) Use ES6 and drop support for node < v4

## **5.2.1**
- [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values

## [**5.2.0**](https://github.com/ljharb/qs/issues?milestone=30&state=closed)
- [**#64**](https://github.com/ljharb/qs/issues/64) Add option to sort object keys in the query string

Expand Down
29 changes: 14 additions & 15 deletions dist/qs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module.exports = {

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

var has = Object.prototype.hasOwnProperty;

var defaults = {
delimiter: '&',
depth: 5,
Expand All @@ -34,21 +36,18 @@ var parseValues = function parseValues(str, options) {
var part = parts[i];
var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;

var key, val;
if (pos === -1) {
obj[options.decoder(part)] = '';

if (options.strictNullHandling) {
obj[options.decoder(part)] = null;
}
key = options.decoder(part);
val = options.strictNullHandling ? null : '';
} else {
var key = options.decoder(part.slice(0, pos));
var val = options.decoder(part.slice(pos + 1));

if (Object.prototype.hasOwnProperty.call(obj, key)) {
obj[key] = [].concat(obj[key]).concat(val);
} else {
obj[key] = val;
}
key = options.decoder(part.slice(0, pos));
val = options.decoder(part.slice(pos + 1));
}
if (has.call(obj, key)) {
obj[key] = [].concat(obj[key]).concat(val);
} else {
obj[key] = val;
}
}

Expand Down Expand Up @@ -110,7 +109,7 @@ var parseKeys = function parseKeys(givenKey, val, options) {
if (segment[1]) {
// If we aren't using plain objects, optionally prefix keys
// that would overwrite object prototype properties
if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1])) {
if (!options.plainObjects && has.call(Object.prototype, segment[1])) {
if (!options.allowPrototypes) {
return;
}
Expand All @@ -124,7 +123,7 @@ var parseKeys = function parseKeys(givenKey, val, options) {
var i = 0;
while ((segment = child.exec(key)) !== null && i < options.depth) {
i += 1;
if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) {
if (!options.plainObjects && has.call(Object.prototype, segment[1].replace(/\[|\]/g, ''))) {
if (!options.allowPrototypes) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "qs",
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
"homepage": "https://github.com/ljharb/qs",
"version": "6.2.0",
"version": "6.2.1",
"repository": {
"type": "git",
"url": "https://github.com/ljharb/qs.git"
Expand Down

0 comments on commit 335f839

Please sign in to comment.