Skip to content

Commit

Permalink
[fixed] Allow special characters in query
Browse files Browse the repository at this point in the history
Previously, special characters in query were left as is, potentially overwriting other query parameters and causing ambiguity.
Now, they are properly escaped.

Fixes remix-run#804.
  • Loading branch information
gaearon committed Feb 11, 2015
1 parent 911073a commit 83c8f59
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/utils/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ var Path = {
var queryString = qs.stringify(query, { indices: false });

if (queryString)
return Path.withoutQuery(path) + '?' + decodeURIComponent(queryString);
return Path.withoutQuery(path) + '?' + queryString;

return path;
},
Expand Down
4 changes: 4 additions & 0 deletions modules/utils/__tests__/Path-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ describe('Path.withQuery', function () {
it('merges two query strings', function () {
expect(Path.withQuery('/path?a=b', { c: [ 'd', 'e' ] })).toEqual('/path?a=b&c=d&c=e');
});

it('handles special characters', function () {
expect(Path.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');
});
});

describe('Path.normalize', function () {
Expand Down

0 comments on commit 83c8f59

Please sign in to comment.