Skip to content

Commit 559c604

Browse files
committed
[changed] Use empty bracket notation for arrays
Query strings use empty brackets for encoding arrays, which has the widest range of support among server-side frameworks. Fixes #901 Fixes #939 May have something to do with #715
1 parent e8a16ef commit 559c604

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

modules/PathUtils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ var PathUtils = {
146146
if (existingQuery)
147147
query = query ? merge(existingQuery, query) : existingQuery;
148148

149-
var queryString = qs.stringify(query, { indices: false });
149+
var queryString = qs.stringify(query, { arrayFormat: 'brackets' });
150150

151151
if (queryString)
152152
return PathUtils.withoutQuery(path) + '?' + queryString;

modules/__tests__/PathUtils-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,10 @@ describe('PathUtils.withQuery', function () {
316316
});
317317

318318
it('merges two query strings', function () {
319-
expect(PathUtils.withQuery('/path?a=b', { c: [ 'd', 'e' ] })).toEqual('/path?a=b&c=d&c=e');
319+
expect(PathUtils.withQuery('/path?a=b', { c: [ 'd', 'e' ] })).toEqual('/path?a=b&c%5B%5D=d&c%5B%5D=e');
320320
});
321321

322322
it('handles special characters', function () {
323-
expect(PathUtils.withQuery('/path?a=b', { c: [ 'd#e', 'f&a=i#j+k' ] })).toEqual('/path?a=b&c=d%23e&c=f%26a%3Di%23j%2Bk');
323+
expect(PathUtils.withQuery('/path?a=b', { c: [ 'd#e', 'f&a=i#j+k' ] })).toEqual('/path?a=b&c%5B%5D=d%23e&c%5B%5D=f%26a%3Di%23j%2Bk');
324324
});
325325
});

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"react": "0.12.x"
4747
},
4848
"dependencies": {
49-
"qs": "2.3.3"
49+
"qs": "2.4.1"
5050
},
5151
"tags": [
5252
"react",

0 commit comments

Comments
 (0)