Skip to content

Commit

Permalink
[changed] Use empty bracket notation for arrays
Browse files Browse the repository at this point in the history
Query strings use empty brackets for encoding arrays, which has
the widest range of support among server-side frameworks.

Fixes remix-run#901
Fixes remix-run#939

May have something to do with remix-run#715
  • Loading branch information
mjackson committed Mar 16, 2015
1 parent e8a16ef commit 559c604
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/PathUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ var PathUtils = {
if (existingQuery)
query = query ? merge(existingQuery, query) : existingQuery;

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

if (queryString)
return PathUtils.withoutQuery(path) + '?' + queryString;
Expand Down
4 changes: 2 additions & 2 deletions modules/__tests__/PathUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ describe('PathUtils.withQuery', function () {
});

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

it('handles special characters', function () {
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');
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');
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"react": "0.12.x"
},
"dependencies": {
"qs": "2.3.3"
"qs": "2.4.1"
},
"tags": [
"react",
Expand Down

0 comments on commit 559c604

Please sign in to comment.