Skip to content

Commit 4b62c7b

Browse files
committed
Merge branch 'release/3.3.0'
2 parents 240c249 + 4062dba commit 4b62c7b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/core/lib/request.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ export default function Request(options) {
1010
let serialize = function(obj, prefix) {
1111
let str = [],
1212
p;
13-
for (p in obj) {
14-
if (obj.hasOwnProperty(p)) {
13+
if (typeof obj === "object" && obj.length !== undefined) {
14+
for (var i = 0, _i = obj.length; i < _i; i++) {
15+
str.push(prefix + '[]=' + obj[i]);
16+
}
17+
} else {
18+
for (p in obj) {
1519
let k = prefix ? prefix + "[" + p + "]" : p,
1620
v = obj[p];
1721
str.push((v !== null && typeof v === "object" && p !== 'query') ?
@@ -31,6 +35,7 @@ export default function Request(options) {
3135

3236
if (options.body && typeof options.body === 'object') {
3337
delete options.body._method;
38+
if (typeof options.body.query === "object" && Object.keys(options.body.query).length === 0) delete options.body.query;
3439
queryParams = serialize(options.body);
3540
}
3641

0 commit comments

Comments
 (0)