Determine service worker script path based on path of main script.
This commit is contained in:
parent
def02e77a7
commit
cc963ebce3
|
@ -10,7 +10,9 @@ function App() {
|
||||||
|
|
||||||
function create() {
|
function create() {
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
navigator.serviceWorker.register('/ipfs/fetcher.js')
|
const this_script_url = document.currentScript.src;
|
||||||
|
const base_script_url = this_script_url.slice(0, this_script_url.lastIndexOf('/'))
|
||||||
|
navigator.serviceWorker.register(base_script_url + '/fetcher.js')
|
||||||
.then((registration) => {
|
.then((registration) => {
|
||||||
console.log('registered the service worker successfully')
|
console.log('registered the service worker successfully')
|
||||||
|
|
||||||
|
|
Reference in New Issue