-
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
admin-manifest: Fix url query param issue #38755
Conversation
Size Change: +114 B (0%) Total Size: 1.15 MB
ℹ️ View Unchanged
|
This reverts commit 697c5a41ab6c782d641c421512e83a23cbc9b6d5.
8034400
to
3bdc8d1
Compare
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.
This tests well! As a sanity-check, I checked the output for addQueryArgs
for a couple of scenarios, and all of them correctly loaded the service worker JSON.
addQueryArgs( "http://localhost:8888/wp-admin", { "service-worker": true } )
"http://localhost:8888/wp-admin?service-worker=true"
addQueryArgs( "http://localhost:8888/wp-admin?something", { "service-worker": true } )
"http://localhost:8888/wp-admin?something=&service-worker=true"
addQueryArgs( "http://localhost:8888/wp-admin?something=true", { "service-worker": true } )
"http://localhost:8888/wp-admin?something=true&service-worker=true"
addQueryArgs( "http://localhost:8888/wp-admin?something=true&another=true", { "service-worker": true } )
"http://localhost:8888/wp-admin?something=true&another=true&service-worker=true"
Just curious, whenever this error happened, that meant the service worker wasn't loaded nor set up, which means the consequences went beyond just an error message in the console, right? 😬
Correct. Whatever features the service worker provides wouldn't have been available. |
Description
It is possible for the
adminUrl
to already have a query parameter, in which case the URL can be set to something likeexample.com/wp-admin/?something=true?service-worker
. If that happens, the service worker fails to register, as the URL doesn't return the expected JSON. The fix is to add the query param in the "canonical" way, with the URL package.Testing Instructions
I am unsure how to test the admin manifest package, but I don't expect this to change anything in most cases.
You could test visiting these URLs to verify that the fix would work. (These URLs operate the same way before and after the PR. We're just changing the code to load the second URL instead of the first.)
localhost:8888/wp-admin?foo=true?service-worker
. This will not return JSON.localhost:8888/wp-admin?foo=true&service-worker=true
. This will return JSON.Screenshots
Types of changes
Bug fix
Checklist:
*.native.js
files for terms that need renaming or removal).