-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
URL: Fix getQueryString incorrect handling of hash fragment #20738
Conversation
Size Change: +353 B (0%) Total Size: 864 kB
ℹ️ View Unchanged
|
As seen with the changes in 0a6046a, the new implementation is slightly more strict in regards to assuming the input argument to be a proper URL, not merely any string which happens to contain
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks correct. I hope it doesn’t break anything in projects that depend on this bug 😅
Previously _sort of_ existed, but as an invalid URL which would fail to construct as `new URL` in the current implementation. Now split to two assertions verifying "invalid URL" behavior and "empty querystring" behavior.
Note that I had to scale this back a bit in #20693. Specifically, there's at least a few occurrences where we rely on an implementation like this: addQueryArgs( '/wp-json/wp/v2/posts`, { type: 'post' } ); And if The solution (8dfe648) is a bit hacky, effectively treating the input URL as the path of a throwaway base (second argument of URL constructor). |
Previously: #11286
Extracted from: #20693
This pull request seeks to fix an incorrect behavior of
@wordpress/url
getQueryString
, where a result may be returned when a?
is encountered within the hash fragment of a URL:A hash fragment is always the last segment of a URL, and the querystring must always precede it (see reference specification).
Testing Instructions:
Ensure unit tests pass: