Skip to content

Commit e3fe3c6

Browse files
authored
chore: set correct serviceWorker path for gh-pages (#80)
* chore: set correct serviceWorker path for gh-pages * chore: add comment
1 parent 25d8973 commit e3fe3c6

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

test/e2e/index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ $("[data-action=setup]")
2121
}
2222
});
2323

24-
let scope = null
24+
let scope = null;
25+
let serviceWorkerUrl = "sw.min.js";
2526
if (window.location.hostname === "leanplum.github.io") {
26-
scope = "/Leanplum-JavaScript-SDK/";
27+
scope = window.location.pathname; // GH-pages guarantees ending slash
28+
serviceWorkerUrl = scope + serviceWorkerUrl;
2729
}
28-
Leanplum.setWebPushOptions({
29-
serviceWorkerUrl: window.origin + window.location.pathname + "/sw.min.js",
30-
scope
31-
})
30+
Leanplum.setWebPushOptions({ serviceWorkerUrl, scope });
3231

3332
$("#registerForWebPush")
3433
.click(() => Leanplum.registerForWebPush().then(refreshWebPush));

0 commit comments

Comments
 (0)