qs 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -200,6 +200,17 @@ Qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false });
200
200
  // 'a=b&a=c&a=d'
201
201
  ```
202
202
 
203
+ You may use the `arrayFormat` option to specify the format of the output array
204
+
205
+ ```javascript
206
+ Qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' })
207
+ // 'a[0]=b&a[1]=c'
208
+ Qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' })
209
+ // 'a[]=b&a[]=c'
210
+ Qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' })
211
+ // 'a=b&a=c'
212
+ ```
213
+
203
214
  Empty strings and null values will omit the value, but the equals sign (=) remains in place:
204
215
 
205
216
  ```javascript
package/lib/parse.js CHANGED
@@ -29,6 +29,10 @@ internals.parseValues = function (str, options) {
29
29
  var key = Utils.decode(part.slice(0, pos));
30
30
  var val = Utils.decode(part.slice(pos + 1));
31
31
 
32
+ if (Object.prototype.hasOwnProperty(key)) {
33
+ continue;
34
+ }
35
+
32
36
  if (!obj.hasOwnProperty(key)) {
33
37
  obj[key] = val;
34
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qs",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "A querystring parser that supports nesting and arrays, with a depth limit",
5
5
  "homepage": "https://github.com/hapijs/qs",
6
6
  "main": "index.js",
package/test/parse.js CHANGED
@@ -187,7 +187,7 @@ describe('parse()', function () {
187
187
 
188
188
  it('cannot override prototypes', function (done) {
189
189
 
190
- var obj = Qs.parse('toString=bad&bad[toString]=bad&constructor=bad');
190
+ var obj = Qs.parse('hasOwnProperty=bad&toString=bad&bad[toString]=bad&constructor=bad');
191
191
  expect(typeof obj.toString).to.equal('function');
192
192
  expect(typeof obj.bad.toString).to.equal('function');
193
193
  expect(typeof obj.constructor).to.equal('function');