Skip to content

Commit

Permalink
admin-manifest: Fix url query param issue (WordPress#38755)
Browse files Browse the repository at this point in the history
* Add query param to admin manifest in a safe way
  • Loading branch information
noahtallen authored Feb 16, 2022
1 parent 7cb61f9 commit 9e34e5f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/admin-manifest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.16.0"
"@babel/runtime": "^7.16.0",
"@wordpress/url": "file:../url"
},
"publishConfig": {
"access": "public"
Expand Down
9 changes: 8 additions & 1 deletion packages/admin-manifest/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* WordPress dependencies
*/
import { addQueryArgs } from '@wordpress/url';

function addManifest( manifest ) {
const link = document.createElement( 'link' );
link.rel = 'manifest';
Expand Down Expand Up @@ -164,6 +169,8 @@ window.addEventListener( 'load', () => {
),
] ).then( () => {
addManifest( manifest );
window.navigator.serviceWorker.register( adminUrl + '?service-worker' );
window.navigator.serviceWorker.register(
addQueryArgs( adminUrl, { 'service-worker': true } )
);
} );
} );

0 comments on commit 9e34e5f

Please sign in to comment.