2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

don’t escape square brackets

This commit is contained in:
Maximilian Hoffmann
2015-07-23 10:46:21 +02:00
parent 594df987f2
commit f44597e38b
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -8,7 +8,9 @@ function encode(val) {
replace(/%3A/gi, ':'). replace(/%3A/gi, ':').
replace(/%24/g, '$'). replace(/%24/g, '$').
replace(/%2C/gi, ','). replace(/%2C/gi, ',').
replace(/%20/g, '+'); replace(/%20/g, '+')
replace(/%5B/gi, '[').
replace(/%5D/gi, ']');
} }
/** /**
@@ -31,7 +33,7 @@ module.exports = function buildUrl(url, params) {
} }
if (utils.isArray(val)) { if (utils.isArray(val)) {
key = key+'[]'; key = key + '[]';
} }
if (!utils.isArray(val)) { if (!utils.isArray(val)) {
+1 -1
View File
@@ -30,7 +30,7 @@ describe('helpers::buildUrl', function () {
it('should support array params', function () { it('should support array params', function () {
expect(buildUrl('/foo', { expect(buildUrl('/foo', {
foo: ['bar', 'baz'] foo: ['bar', 'baz']
})).toEqual('/foo?foo%5B%5D=bar&foo%5B%5D=baz'); })).toEqual('/foo?foo[]=bar&foo[]=baz');
}); });
it('should support special char params', function () { it('should support special char params', function () {