qs 2.2.1 → 2.2.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 +56 -0
- package/lib/parse.js +7 -7
- package/lib/utils.js +5 -38
- package/package.json +1 -1
- package/test/parse.js +26 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
## [**2.2.2**](https://github.com/hapijs/qs/issues?milestone=11&state=open)
|
|
3
|
+
- [**#34**](https://github.com/hapijs/qs/issues/34) use Object.prototype.hasOwnProperty.call instead of obj.hasOwnProperty
|
|
4
|
+
- [**#24**](https://github.com/hapijs/qs/issues/24) Changelog? Semver?
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# 2014-08-28
|
|
10
|
+
95 commits against 24 issues, over a month [`32edf33`](https://github.com/hapijs/qs/commit/32edf33)⎆[`b1e7b53`](https://github.com/hapijs/qs/commit/b1e7b53)
|
|
11
|
+
|
|
12
|
+
## [**2.2.1**](https://github.com/hapijs/qs/issues?milestone=10&state=closed)
|
|
13
|
+
- [**#32**](https://github.com/hapijs/qs/issues/32) account for circular references properly, closes #31
|
|
14
|
+
- [**#31**](https://github.com/hapijs/qs/issues/31) qs.parse stackoverflow on circular objects
|
|
15
|
+
|
|
16
|
+
## [**2.2.0**](https://github.com/hapijs/qs/issues?milestone=9&state=closed)
|
|
17
|
+
- [**#30**](https://github.com/hapijs/qs/issues/30) Bug when merging non-object values into arrays
|
|
18
|
+
- [**#29**](https://github.com/hapijs/qs/issues/29) Don't call Utils.clone at the top of Utils.merge
|
|
19
|
+
- [**#26**](https://github.com/hapijs/qs/issues/26) Don't use Buffer global if it's not present
|
|
20
|
+
- [**#23**](https://github.com/hapijs/qs/issues/23) Ability to not limit parameters?
|
|
21
|
+
|
|
22
|
+
## [**2.1.0**](https://github.com/hapijs/qs/issues?milestone=8&state=closed)
|
|
23
|
+
- [**#22**](https://github.com/hapijs/qs/issues/22) Enable using a RegExp as delimiter
|
|
24
|
+
|
|
25
|
+
## [**2.0.0**](https://github.com/hapijs/qs/issues?milestone=7&state=closed)
|
|
26
|
+
- [**#20**](https://github.com/hapijs/qs/issues/20) Configurable parametersLimit
|
|
27
|
+
- [**#18**](https://github.com/hapijs/qs/issues/18) Why is there arrayLimit?
|
|
28
|
+
- [**#21**](https://github.com/hapijs/qs/issues/21) make all limits optional, for #18, for #20
|
|
29
|
+
|
|
30
|
+
## [**1.2.2**](https://github.com/hapijs/qs/issues?milestone=6&state=closed)
|
|
31
|
+
- [**#19**](https://github.com/hapijs/qs/issues/19) Don't overwrite null values
|
|
32
|
+
|
|
33
|
+
## [**1.2.1**](https://github.com/hapijs/qs/issues?milestone=5&state=closed)
|
|
34
|
+
- [**#16**](https://github.com/hapijs/qs/issues/16) ignore non-string delimiters
|
|
35
|
+
- [**#15**](https://github.com/hapijs/qs/issues/15) Close code block
|
|
36
|
+
|
|
37
|
+
## [**1.2.0**](https://github.com/hapijs/qs/issues?milestone=4&state=closed)
|
|
38
|
+
- [**#12**](https://github.com/hapijs/qs/issues/12) Add optional delim argument
|
|
39
|
+
- [**#13**](https://github.com/hapijs/qs/issues/13) fix #11: flattened keys in array are now correctly parsed
|
|
40
|
+
|
|
41
|
+
## [**1.1.0**](https://github.com/hapijs/qs/issues?milestone=3&state=closed)
|
|
42
|
+
- [**#7**](https://github.com/hapijs/qs/issues/7) Empty values of a POST array disappear after being submitted
|
|
43
|
+
- [**#9**](https://github.com/hapijs/qs/issues/9) Should not omit equals signs (=) when value is null
|
|
44
|
+
- [**#6**](https://github.com/hapijs/qs/issues/6) Minor grammar fix in README
|
|
45
|
+
|
|
46
|
+
## [**1.0.2**](https://github.com/hapijs/qs/issues?milestone=2&state=closed)
|
|
47
|
+
- [**#5**](https://github.com/hapijs/qs/issues/5) array holes incorrectly copied into object on large index
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## Issues
|
|
51
|
+
- [**#25**](https://github.com/hapijs/qs/issues/25) Remove references to Buffer
|
|
52
|
+
- [**#11**](https://github.com/hapijs/qs/issues/11) Flattened keys in array does not parse correctly
|
|
53
|
+
- [**#8**](https://github.com/hapijs/qs/issues/8) Square brackets should be URI encoded
|
|
54
|
+
- [**#3**](https://github.com/hapijs/qs/issues/3) Update README.md
|
|
55
|
+
- [**#2**](https://github.com/hapijs/qs/issues/2) Add travis and rework package
|
|
56
|
+
|
package/lib/parse.js
CHANGED
|
@@ -138,16 +138,16 @@ module.exports = function (str, options) {
|
|
|
138
138
|
options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit;
|
|
139
139
|
options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit;
|
|
140
140
|
|
|
141
|
-
var tempObj = typeof str === 'string' ? internals.parseValues(str, options) :
|
|
141
|
+
var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str;
|
|
142
142
|
var obj = {};
|
|
143
143
|
|
|
144
144
|
// Iterate over the keys and setup the new object
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
145
|
+
|
|
146
|
+
var keys = Object.keys(tempObj);
|
|
147
|
+
for (var i = 0, il = keys.length; i < il; ++i) {
|
|
148
|
+
var key = keys[i];
|
|
149
|
+
var newObj = internals.parseKeys(key, tempObj[key], options);
|
|
150
|
+
obj = Utils.merge(obj, newObj);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
return Utils.compact(obj);
|
package/lib/utils.js
CHANGED
|
@@ -20,39 +20,6 @@ exports.arrayToObject = function (source) {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
exports.clone = function (source, refs) {
|
|
24
|
-
|
|
25
|
-
if (typeof source !== 'object' ||
|
|
26
|
-
source === null) {
|
|
27
|
-
|
|
28
|
-
return source;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (exports.isBuffer(source)) {
|
|
32
|
-
return source.toString();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
refs = refs || [];
|
|
36
|
-
|
|
37
|
-
var lookup = refs.indexOf(source);
|
|
38
|
-
if (lookup !== -1) {
|
|
39
|
-
return refs[lookup];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var copy = Array.isArray(source) ? [] : source;
|
|
43
|
-
|
|
44
|
-
refs.push(source);
|
|
45
|
-
|
|
46
|
-
for (var i in source) {
|
|
47
|
-
if (source.hasOwnProperty(i)) {
|
|
48
|
-
copy[i] = exports.clone(source[i], refs);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return copy;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
|
|
56
23
|
exports.merge = function (target, source) {
|
|
57
24
|
|
|
58
25
|
if (!source) {
|
|
@@ -93,7 +60,7 @@ exports.merge = function (target, source) {
|
|
|
93
60
|
typeof value === 'object') {
|
|
94
61
|
|
|
95
62
|
if (!target[key]) {
|
|
96
|
-
target[key] =
|
|
63
|
+
target[key] = value;
|
|
97
64
|
}
|
|
98
65
|
else {
|
|
99
66
|
target[key] = exports.merge(target[key], value);
|
|
@@ -146,10 +113,10 @@ exports.compact = function (obj, refs) {
|
|
|
146
113
|
return compacted;
|
|
147
114
|
}
|
|
148
115
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
116
|
+
var keys = Object.keys(obj);
|
|
117
|
+
for (var i = 0, il = keys.length; i < il; ++i) {
|
|
118
|
+
var key = keys[i];
|
|
119
|
+
obj[key] = exports.compact(obj[key], refs);
|
|
153
120
|
}
|
|
154
121
|
|
|
155
122
|
return obj;
|
package/package.json
CHANGED
package/test/parse.js
CHANGED
|
@@ -205,10 +205,10 @@ describe('#parse', function () {
|
|
|
205
205
|
done();
|
|
206
206
|
});
|
|
207
207
|
|
|
208
|
-
it('parses buffers
|
|
208
|
+
it('parses buffers correctly', function (done) {
|
|
209
209
|
|
|
210
210
|
var b = new Buffer('test');
|
|
211
|
-
expect(Qs.parse({ a: b })).to.deep.equal({ a: b
|
|
211
|
+
expect(Qs.parse({ a: b })).to.deep.equal({ a: b });
|
|
212
212
|
done();
|
|
213
213
|
});
|
|
214
214
|
|
|
@@ -356,4 +356,28 @@ describe('#parse', function () {
|
|
|
356
356
|
expect(parsed.foo.baz).to.deep.equal(a);
|
|
357
357
|
done();
|
|
358
358
|
});
|
|
359
|
+
|
|
360
|
+
it('parses plain objects correctly', function (done) {
|
|
361
|
+
|
|
362
|
+
var a = Object.create(null);
|
|
363
|
+
a.b = 'c';
|
|
364
|
+
|
|
365
|
+
expect(Qs.parse(a)).to.deep.equal({ b: 'c' });
|
|
366
|
+
expect(Qs.parse({ a: a })).to.deep.equal({ a: { b: 'c' } });
|
|
367
|
+
done();
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it('parses dates correctly', function (done) {
|
|
371
|
+
|
|
372
|
+
var now = new Date();
|
|
373
|
+
expect(Qs.parse({ a: now })).to.deep.equal({ a: now });
|
|
374
|
+
done();
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
it('parses regular expressions correctly', function (done) {
|
|
378
|
+
|
|
379
|
+
var re = /^test$/;
|
|
380
|
+
expect(Qs.parse({ a: re })).to.deep.equal({ a: re });
|
|
381
|
+
done();
|
|
382
|
+
});
|
|
359
383
|
});
|