Comparing version 3.5.0 to 3.5.1
@@ -26,15 +26,9 @@ 'use strict'; | ||
/** | ||
* Stringifies an Object, accommodating a single-level of nested objects | ||
* Stringifies an Object, accommodating nested objects | ||
* (forming the conventional key "parent[child]=value") | ||
*/ | ||
stringifyRequestData: function(data, _key) { | ||
stringifyRequestData: function(data) { | ||
if (data.expand) { | ||
data = _.cloneDeep(data); | ||
data['expand[]'] = data.expand; | ||
delete data.expand; | ||
} | ||
return qs.stringify(data, {arrayFormat: 'brackets'}); | ||
return qs.stringify(data, {indices: false}); | ||
}, | ||
@@ -41,0 +35,0 @@ |
{ | ||
"name": "stripe", | ||
"version": "3.5.0", | ||
"version": "3.5.1", | ||
"description": "Stripe API wrapper", | ||
@@ -35,3 +35,3 @@ "keywords": [ | ||
"bluebird": "^2.9.6", | ||
"qs": "^2.3.3", | ||
"qs": "^2.4.1", | ||
"lodash": "^3.1.0" | ||
@@ -38,0 +38,0 @@ }, |
@@ -40,3 +40,3 @@ 'use strict'; | ||
it('Handles deeply nested object', function() { | ||
expect(utils.stringifyRequestData({ | ||
expect(decodeURI(utils.stringifyRequestData({ | ||
a: { | ||
@@ -49,5 +49,14 @@ b: { | ||
} | ||
})).to.equal('a%5Bb%5D%5Bc%5D%5Bd%5D=2'); | ||
}))).to.equal('a[b][c][d]=2'); | ||
}); | ||
it('Handles arrays of objects', function() { | ||
expect(decodeURI(utils.stringifyRequestData({ | ||
a: [ | ||
{ b: 'c' }, | ||
{ b: 'd' }, | ||
] | ||
}))).to.equal('a[][b]=c&a[][b]=d'); | ||
}) | ||
it('Creates a string from an object, handling shallow nested objects', function() { | ||
@@ -74,5 +83,5 @@ expect(utils.stringifyRequestData({ | ||
it('Handles the `expand` array correctly (producing the form `expand[]=_` for each item', function() { | ||
expect(utils.stringifyRequestData({ | ||
expect(decodeURI(utils.stringifyRequestData({ | ||
expand: ['a', 'foo', 'a.b.c'] | ||
})).to.equal('expand%5B%5D=a&expand%5B%5D=foo&expand%5B%5D=a.b.c'); | ||
}))).to.equal('expand[]=a&expand[]=foo&expand[]=a.b.c'); | ||
}); | ||
@@ -79,0 +88,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
164067
4441
Updatedqs@^2.4.1