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
|
gziolo
left a comment
There was a problem hiding this comment.
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/urlgetQueryString, 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: