-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Avoid erroring when getQueryArgs processes a malformed URL #45561
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
Changes from all commits
a85e3d9
4669991
f311dcb
3550425
8a3d7b0
cbb9a3d
9a803c1
e5b754b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -723,6 +723,16 @@ describe( 'getQueryArgs', () => { | |
| ) | ||
| ).toEqual( data ); | ||
| } ); | ||
|
|
||
| it( 'should not blow up on malformed params', () => { | ||
| const url = 'https://andalouses.example/beach?foo=bar&baz=%E0%A4%A'; | ||
|
|
||
| expect( () => getQueryArgs( url ) ).not.toThrow(); | ||
| expect( getQueryArgs( url ) ).toEqual( { | ||
| baz: '%E0%A4%A', | ||
| foo: 'bar', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PHP's
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, @danielbachhuber for pointing this out. I wasn't familiar with that. Please note, that although this is a step to the right direction, will minimally affect the issue we have in calypso. Calypso uses two ways to parse URLs:
This internally uses the I proposed to add that inside the calypso We can create a ticket to remove qs library of course, but this is a huge take and I think it's better if we do it incrementally. Maybe we should communicate that also to the calypso channel as well? Any thoughts? Thank you!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@kozer I'm not sure
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I kind of agree with this. Is there is a reason not to return the value? You could just replace
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Raising another hand of agreement. I think using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ntsekouras , @tyxla I did the changes you proposed. Thanks so much!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for taking care of that, @kozer, looks great 🙌 |
||
| } ); | ||
| } ); | ||
| } ); | ||
| } ); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.