修复url带有文件名时serviceWorker注册失败的问题
This commit is contained in:
parent
a4e4998afc
commit
91edb35780
|
@ -134,7 +134,7 @@
|
|||
|
||||
// 使serviceWorker加载完成后,再加载entry.js
|
||||
if (location.protocol.startsWith("http") && "serviceWorker" in navigator) {
|
||||
let scope = window.location.protocol + "//" + window.location.host + window.location.pathname;
|
||||
let scope = (new URL("./", location.href)).toString();
|
||||
let registrations = await navigator.serviceWorker.getRegistrations();
|
||||
let findServiceWorker = registrations.find(registration => {
|
||||
return registration && registration.active && registration.active.scriptURL == `${scope}service-worker.js`;
|
||||
|
|
Loading…
Reference in New Issue