Comparing version 6.2.0 to 6.2.1
@@ -0,1 +1,8 @@ | ||
## **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) | ||
@@ -20,2 +27,5 @@ - [New] pass Buffers to the encoder/decoder directly (#161) | ||
## **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) | ||
@@ -22,0 +32,0 @@ - [**#64**](https://github.com/ljharb/qs/issues/64) Add option to sort object keys in the query string |
@@ -17,2 +17,4 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Qs = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var has = Object.prototype.hasOwnProperty; | ||
var defaults = { | ||
@@ -38,18 +40,15 @@ delimiter: '&', | ||
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; | ||
} | ||
} | ||
@@ -115,3 +114,3 @@ | ||
// 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) { | ||
@@ -130,3 +129,3 @@ return; | ||
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) { | ||
@@ -133,0 +132,0 @@ continue; |
@@ -5,2 +5,4 @@ 'use strict'; | ||
var has = Object.prototype.hasOwnProperty; | ||
var defaults = { | ||
@@ -26,18 +28,15 @@ delimiter: '&', | ||
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; | ||
} | ||
} | ||
@@ -103,3 +102,3 @@ | ||
// 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) { | ||
@@ -118,3 +117,3 @@ return; | ||
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) { | ||
@@ -121,0 +120,0 @@ continue; |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://github.com/ljharb/qs", | ||
"version": "6.2.0", | ||
"version": "6.2.1", | ||
"repository": { | ||
@@ -29,13 +29,14 @@ "type": "git", | ||
"browserify": "^13.0.1", | ||
"tape": "^4.5.1", | ||
"tape": "^4.6.0", | ||
"covert": "^1.1.0", | ||
"mkdirp": "^0.5.1", | ||
"eslint": "^2.9.0", | ||
"@ljharb/eslint-config": "^4.0.0", | ||
"eslint": "^3.1.0", | ||
"@ljharb/eslint-config": "^6.0.0", | ||
"parallelshell": "^2.0.0", | ||
"iconv-lite": "^0.4.13", | ||
"qs-iconv": "^1.0.3", | ||
"evalmd": "^0.0.17" | ||
}, | ||
"scripts": { | ||
"pretest": "parallelshell 'npm run --silent readme' 'npm run --silent lint'", | ||
"pretest": "npm run --silent readme && npm run --silent lint", | ||
"test": "npm run --silent coverage", | ||
@@ -42,0 +43,0 @@ "tests-only": "node test", |
@@ -124,4 +124,7 @@ 'use strict'; | ||
st.deepEqual(qs.parse('foo[0][a]=a&foo[0][b]=b&foo[1][a]=aa&foo[1][b]=bb'), { foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] }); | ||
st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c'), { a: { '0': 'b', t: 'u', c: true } }); | ||
st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y'), { a: { '0': 'b', '1': 'c', x: 'y' } }); | ||
st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: false }), { a: { '0': 'b', c: true, t: 'u' } }); | ||
st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: true }), { a: { '0': 'b', t: 'u', hasOwnProperty: 'c' } }); | ||
st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: false }), { a: { '0': 'b', '1': 'c', x: 'y' } }); | ||
st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: true }), { a: { '0': 'b', hasOwnProperty: 'c', x: 'y' } }); | ||
st.end(); | ||
@@ -178,5 +181,30 @@ }); | ||
st.deepEqual(qs.parse('a[]=b&a[]=&a[]=c'), { a: ['b', '', 'c'] }); | ||
st.deepEqual(qs.parse('a[0]=b&a[1]&a[2]=c&a[19]=', { strictNullHandling: true }), { a: ['b', null, 'c', ''] }); | ||
st.deepEqual(qs.parse('a[0]=b&a[1]=&a[2]=c&a[19]', { strictNullHandling: true }), { a: ['b', '', 'c', null] }); | ||
st.deepEqual(qs.parse('a[]=&a[]=b&a[]=c'), { a: ['', 'b', 'c'] }); | ||
st.deepEqual( | ||
qs.parse('a[0]=b&a[1]&a[2]=c&a[19]=', { strictNullHandling: true, arrayLimit: 20 }), | ||
{ a: ['b', null, 'c', ''] }, | ||
'with arrayLimit 20 + array indices: null then empty string works' | ||
); | ||
st.deepEqual( | ||
qs.parse('a[]=b&a[]&a[]=c&a[]=', { strictNullHandling: true, arrayLimit: 0 }), | ||
{ a: ['b', null, 'c', ''] }, | ||
'with arrayLimit 0 + array brackets: null then empty string works' | ||
); | ||
st.deepEqual( | ||
qs.parse('a[0]=b&a[1]=&a[2]=c&a[19]', { strictNullHandling: true, arrayLimit: 20 }), | ||
{ a: ['b', '', 'c', null] }, | ||
'with arrayLimit 20 + array indices: empty string then null works' | ||
); | ||
st.deepEqual( | ||
qs.parse('a[]=b&a[]=&a[]=c&a[]', { strictNullHandling: true, arrayLimit: 0 }), | ||
{ a: ['b', '', 'c', null] }, | ||
'with arrayLimit 0 + array brackets: empty string then null works' | ||
); | ||
st.deepEqual( | ||
qs.parse('a[]=&a[]=b&a[]=c'), | ||
{ a: ['', 'b', 'c'] }, | ||
'array brackets: empty strings work' | ||
); | ||
st.end(); | ||
@@ -183,0 +211,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
82696
0
377
10
1423