Skip to content

Commit

Permalink
Admin PWA: Encode manifest data (#33310)
Browse files Browse the repository at this point in the history
Fixes spaces in site title without replacing them with non breaking spaces.
  • Loading branch information
Petter Walbø Johnsgård committed Jul 8, 2021
1 parent ad0cc77 commit 34d1a96
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/admin-manifest/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
function addManifest( manifest ) {
const link = document.createElement( 'link' );
link.rel = 'manifest';
link.href = 'data:application/manifest+json,' + JSON.stringify( manifest );
link.href = `data:application/manifest+json,${ encodeURIComponent(
JSON.stringify( manifest )
) }`;
document.head.appendChild( link );
}

Expand Down Expand Up @@ -94,8 +96,7 @@ window.addEventListener( 'load', () => {

const { logo, siteTitle, adminUrl } = window.wpAdminManifestL10n;
const manifest = {
// Replace spaces with non breaking spaces. Chrome collapses them.
name: siteTitle.replace( / /g, ' ' ),
name: siteTitle,
display: 'standalone',
orientation: 'portrait',
start_url: adminUrl,
Expand Down

0 comments on commit 34d1a96

Please sign in to comment.