qs 0.5.5 → 0.5.6
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/History.md +5 -0
- package/component.json +1 -1
- package/examples.js +1 -1
- package/index.js +2 -0
- package/package.json +1 -1
- package/test/parse.js +6 -1
- package/test/stringify.js +2 -1
package/History.md
CHANGED
package/component.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "querystring",
|
|
3
3
|
"repo": "visionmedia/node-querystring",
|
|
4
4
|
"description": "query-string parser / stringifier with nesting support",
|
|
5
|
-
"version": "0.5.
|
|
5
|
+
"version": "0.5.6",
|
|
6
6
|
"keywords": ["querystring", "query", "parser"],
|
|
7
7
|
"scripts": ["index.js"],
|
|
8
8
|
"license": "MIT"
|
package/examples.js
CHANGED
package/index.js
CHANGED
|
@@ -107,6 +107,7 @@ function parseString(str){
|
|
|
107
107
|
|
|
108
108
|
// ?foo
|
|
109
109
|
if ('' == key) key = pair, val = '';
|
|
110
|
+
if ('' == key) return ret;
|
|
110
111
|
|
|
111
112
|
return merge(ret, decode(key), decode(val));
|
|
112
113
|
}, { base: {} }).base;
|
|
@@ -195,6 +196,7 @@ function stringifyObject(obj, prefix) {
|
|
|
195
196
|
|
|
196
197
|
for (var i = 0, len = keys.length; i < len; ++i) {
|
|
197
198
|
key = keys[i];
|
|
199
|
+
if ('' == key) continue;
|
|
198
200
|
if (null == obj[key]) {
|
|
199
201
|
ret.push(encodeURIComponent(key) + '=');
|
|
200
202
|
} else {
|
package/package.json
CHANGED
package/test/parse.js
CHANGED
|
@@ -144,4 +144,9 @@ describe('qs.parse()', function(){
|
|
|
144
144
|
expect(qs.parse({ 'user[name]': 'tobi', 'user[email][main]': 'tobi@lb.com' }))
|
|
145
145
|
.to.eql({ user: { name: 'tobi', email: { main: 'tobi@lb.com' } }});
|
|
146
146
|
})
|
|
147
|
-
|
|
147
|
+
|
|
148
|
+
it('should not produce empty keys', function(){
|
|
149
|
+
expect(qs.parse('_r=1&'))
|
|
150
|
+
.to.eql({ _r: '1' })
|
|
151
|
+
})
|
|
152
|
+
})
|
package/test/stringify.js
CHANGED
|
@@ -17,7 +17,8 @@ var str_identities = {
|
|
|
17
17
|
{ str: 'my%20weird%20field=q1!2%22\'w%245%267%2Fz8)%3F', obj: {'my weird field': "q1!2\"'w$5&7/z8)?"}},
|
|
18
18
|
{ str: 'foo%3Dbaz=bar', obj: {'foo=baz': 'bar'}},
|
|
19
19
|
{ str: 'foo=bar&bar=baz', obj: {foo: 'bar', bar: 'baz'}},
|
|
20
|
-
{ str: 'foo=bar&baz=&raz=', obj: { foo: 'bar', baz: null, raz: undefined }}
|
|
20
|
+
{ str: 'foo=bar&baz=&raz=', obj: { foo: 'bar', baz: null, raz: undefined }},
|
|
21
|
+
{ str: 'foo=bar', obj: { foo: 'bar', '':'' }}
|
|
21
22
|
],
|
|
22
23
|
'escaping': [
|
|
23
24
|
{ str: 'foo=foo%20bar', obj: {foo: 'foo bar'}},
|