qs 2.3.1 → 2.3.2

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/CHANGELOG.md CHANGED
@@ -1,10 +1,13 @@
1
1
 
2
- ## [**2.3.0**](https://github.com/hapijs/qs/issues?milestone=15&state=open)
2
+ ## [**2.3.1**](https://github.com/hapijs/qs/issues?milestone=16&state=closed)
3
+ - [**#52**](https://github.com/hapijs/qs/issues/52) Return "undefined" and "false" instead of throwing "TypeError".
4
+
5
+ ## [**2.3.0**](https://github.com/hapijs/qs/issues?milestone=15&state=closed)
3
6
  - [**#50**](https://github.com/hapijs/qs/issues/50) add option to omit array indices, closes #46
4
7
 
5
8
  ## [**2.2.5**](https://github.com/hapijs/qs/issues?milestone=14&state=closed)
6
- - [**#49**](https://github.com/hapijs/qs/issues/49) refactor utils.merge, fixes #45
7
9
  - [**#39**](https://github.com/hapijs/qs/issues/39) Is there an alternative to Buffer.isBuffer?
10
+ - [**#49**](https://github.com/hapijs/qs/issues/49) refactor utils.merge, fixes #45
8
11
  - [**#41**](https://github.com/hapijs/qs/issues/41) avoid browserifying Buffer, for #39
9
12
 
10
13
  ## [**2.2.4**](https://github.com/hapijs/qs/issues?milestone=13&state=closed)
package/lib/utils.js CHANGED
@@ -27,7 +27,13 @@ exports.merge = function (target, source) {
27
27
  }
28
28
 
29
29
  if (typeof source !== 'object') {
30
- target.push(source);
30
+ if (Array.isArray(target)) {
31
+ target.push(source);
32
+ }
33
+ else {
34
+ target[source] = true;
35
+ }
36
+
31
37
  return target;
32
38
  }
33
39
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qs",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
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
@@ -158,6 +158,12 @@ describe('parse()', function () {
158
158
  done();
159
159
  });
160
160
 
161
+ it('can add keys to objects', function (done) {
162
+
163
+ expect(Qs.parse('a[b]=c&a=d')).to.deep.equal({ a: { b: 'c', d: true } });
164
+ done();
165
+ });
166
+
161
167
  it('correctly prunes undefined values when converting an array to an object', function (done) {
162
168
 
163
169
  expect(Qs.parse('a[2]=b&a[99999999]=c')).to.deep.equal({ a: { '2': 'b', '99999999': 'c' } });
@@ -378,7 +384,7 @@ describe('parse()', function () {
378
384
 
379
385
  var a = Object.create(null);
380
386
  a.b = 'c';
381
-
387
+
382
388
  expect(Qs.parse(a)).to.deep.equal({ b: 'c' });
383
389
  expect(Qs.parse({ a: a })).to.deep.equal({ a: { b: 'c' } });
384
390
  done();