Skip to content

Commit

Permalink
fix: avoid sw.js being loaded from wrong path
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-drexler authored and dmbch committed Feb 23, 2018
1 parent 4fd8f21 commit 14ec44b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -144,6 +146,7 @@ function normalizeURLs(config) {
}),
basePath: basePath,
assetPath: assetPath,
workerPath: workerPath,
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/pwa/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
}
});
Expand Down

0 comments on commit 14ec44b

Please sign in to comment.