提交 3b10b6a6 编写于 作者: M Matt Zabriskie

Merge pull request #49 from maxhoffmann/master

Fixing arrays in get params
......@@ -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, ']');
}
/**
......@@ -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];
}
......
......@@ -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 () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册