Skip to content

Commit 6d84189

Browse files
fix(params): removing '[' and ']' from URL encode exclude characters (#3316) (#5715)
Co-authored-by: Jay <[email protected]>
1 parent 0dbb7fd commit 6d84189

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lib/helpers/buildURL.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ function encode(val) {
1616
replace(/%3A/gi, ':').
1717
replace(/%24/g, '$').
1818
replace(/%2C/gi, ',').
19-
replace(/%20/g, '+').
20-
replace(/%5B/gi, '[').
21-
replace(/%5D/gi, ']');
19+
replace(/%20/g, '+');
2220
}
2321

2422
/**

test/specs/helpers/buildURL.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('helpers::buildURL', function () {
3737
foo: {
3838
bar: 'baz'
3939
}
40-
})).toEqual('/foo?foo[bar]=baz');
40+
})).toEqual('/foo?foo%5Bbar%5D=baz');
4141
});
4242

4343
it('should support date params', function () {
@@ -48,10 +48,10 @@ describe('helpers::buildURL', function () {
4848
})).toEqual('/foo?date=' + date.toISOString());
4949
});
5050

51-
it('should support array params', function () {
51+
it('should support array params with encode', function () {
5252
expect(buildURL('/foo', {
53-
foo: ['bar', 'baz', null, undefined]
54-
})).toEqual('/foo?foo[]=bar&foo[]=baz');
53+
foo: ['bar', 'baz']
54+
})).toEqual('/foo?foo%5B%5D=bar&foo%5B%5D=baz');
5555
});
5656

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

0 commit comments

Comments
 (0)