Compare commits

...

1 Commits

Author SHA1 Message Date
Horatiu Muresan
c9974eb28b chore(pwa) Check if manifest exists 2024-01-17 13:27:00 +02:00

View File

@@ -22,10 +22,32 @@
: pathname.substring(0, contextRootEndIndex + 1)
);
}
function getPwaLink() {
return window.location.origin + contextRoot(window.location.pathname) + 'manifest.json'
}
function validateLink(link) {
return fetch(link)
.then(resp => resp.ok && resp.headers?.get('Content-type')=== 'application/json')
.catch(e => false);
}
window.EXCALIDRAW_ASSET_PATH = 'libs/';
// Dynamically generate the manifest location URL. It must be served from the document origin, and we may have
// the base pointing to the CDN. This way we can generate a full URL which will bypass the base.
document.querySelector('#manifest-placeholder').setAttribute('href', window.location.origin + contextRoot(window.location.pathname) + 'manifest.json');
const pwaManifestLink = getPwaLink();
validateLink(pwaManifestLink).then(success => {
const manifestElement = document.querySelector('#manifest-placeholder');
if (success) {
// Dynamically generate the manifest location URL. It must be served from the document origin, and we may have
// the base pointing to the CDN. This way we can generate a full URL which will bypass the base.
manifestElement.setAttribute('href', pwaManifestLink)
} else {
manifestElement.remove();
}
});
document.addEventListener('DOMContentLoaded', () => {
if (!JitsiMeetJS.app) {