Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(parseQueryString): do not remove '+' from query #31

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export function parseQueryString(queryString: string): Object {
query = query.substr(1);
}

let pairs = query.replace(/\+/g, ' ').split('&');
let pairs = query.split('&');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't yield the desired behavior. + literals are spaces.

for (let i = 0; i < pairs.length; i++) {
let pair = pairs[i].split('=');
let key = decodeURIComponent(pair[0]);
Expand Down
2 changes: 2 additions & 0 deletions test/path.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,5 +272,7 @@ describe('query strings', () => {
expect(parse('a[b][c][d]=e')).toEqual({a: {b: {c: {d: 'e'}}}});
expect(parse('a[b][]=c&a[b][]=d&a[b][2][]=f&a[b][2][]=g')).toEqual({a: {b: ['c','d', ['f', 'g']]}});
expect(parse('a[0]=b')).toEqual({a: ['b']});

expect(parse('a=b+c')).toEqual({a: 'b+c'});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect(parse('a=b+c')).toEqual({a: 'b c'});
expect(parse('a=b%2Bc')).toEqual({a: 'b+c'});

I would pull if these tests pass. Fair?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first line is exactly what I was trying to fix. If I pass %2B in a parameter it gets decoded in aurelia-browser-history and arrives as a '+', which is then replaced

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to close the PR if aurelia-browser-history gets fixed. As of now, this is a pretty serious bug which prevents using Asp.net Identity completely

});
});