Try to be less dumb about insecure hosting
This commit is contained in:
parent
448111b8b8
commit
9684a82327
@ -16,7 +16,13 @@ function go() {
|
||||
router.start('home');
|
||||
}
|
||||
|
||||
if ('serviceWorker' in navigator && window.top === window) {
|
||||
const url = `https://${location.host}${location.pathname}${location.hash}`;
|
||||
const msg = `This photo gallery will not work properly unless accessed securely. Connect to ${url} instead?`;
|
||||
|
||||
// We use subtleCrypto which is only available from secure domains and localhost.
|
||||
if (location.protocol !== 'https:' && (!crypto.subtle || !crypto.subtle.digest) && confirm(msg)) {
|
||||
location.assign(url);
|
||||
} else if ('serviceWorker' in navigator && window.top === window) {
|
||||
navigator.serviceWorker
|
||||
.register('/assets/sw.bundle.js', { scope: '/' })
|
||||
.then(go)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user