Skip to content

Commit

Permalink
Merge 2209226 into 183e592
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilian Hoffmann committed Jul 23, 2015
2 parents 183e592 + 2209226 commit 43a610e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/helpers/buildUrl.js
Expand Up @@ -8,7 +8,9 @@ function encode(val) {
replace(/%3A/gi, ':').
replace(/%24/g, '$').
replace(/%2C/gi, ',').
replace(/%20/g, '+');
replace(/%20/g, '+').
replace(/%5B/gi, '[').
replace(/%5D/gi, ']');
}

/**
Expand All @@ -29,6 +31,11 @@ module.exports = function buildUrl(url, params) {
if (val === null || typeof val === 'undefined') {
return;
}

if (utils.isArray(val)) {
key = key + '[]';
}

if (!utils.isArray(val)) {
val = [val];
}
Expand Down
2 changes: 1 addition & 1 deletion test/specs/helpers/buildUrl.spec.js
Expand Up @@ -30,7 +30,7 @@ describe('helpers::buildUrl', function () {
it('should support array params', function () {
expect(buildUrl('/foo', {
foo: ['bar', 'baz']
})).toEqual('/foo?foo=bar&foo=baz');
})).toEqual('/foo?foo[]=bar&foo[]=baz');
});

it('should support special char params', function () {
Expand Down

0 comments on commit 43a610e

Please sign in to comment.