From 14ec44b04198524165ddcf838f4e34340ee61704 Mon Sep 17 00:00:00 2001 From: Robin Drexler Date: Fri, 23 Feb 2018 11:09:20 +0100 Subject: [PATCH] fix: avoid sw.js being loaded from wrong path --- packages/config/index.js | 3 +++ packages/pwa/dom.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/config/index.js b/packages/config/index.js index 704559c6c..16c906454 100644 --- a/packages/config/index.js +++ b/packages/config/index.js @@ -134,6 +134,8 @@ function resolvePaths(config) { function normalizeURLs(config) { var basePath = config.basePath.replace(/^\/*/, '/').replace(/\/*$/, ''); var assetPath = config.assetPath.replace(/(^\/*|\/*$)/g, ''); + var workerPath = config.workerPath.replace(/^\/*/, '/'); + return Object.assign({}, config, { locations: config.locations .map(function(location) { @@ -144,6 +146,7 @@ function normalizeURLs(config) { }), basePath: basePath, assetPath: assetPath, + workerPath: workerPath, }); } diff --git a/packages/pwa/dom.js b/packages/pwa/dom.js index 854fbc3e1..9c9ac6613 100644 --- a/packages/pwa/dom.js +++ b/packages/pwa/dom.js @@ -15,7 +15,7 @@ module.exports = function installServiceWorker() { window.location.hostname === 'localhost' ) { window.addEventListener('load', function() { - resolve(navigator.serviceWorker.register('/' + hopsConfig.workerPath)); + resolve(navigator.serviceWorker.register(hopsConfig.workerPath)); }); } });