Skip to content

Commit 14ec44b

Browse files
robin-drexlerdmbch
authored andcommitted
fix: avoid sw.js being loaded from wrong path
1 parent 4fd8f21 commit 14ec44b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/config/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ function resolvePaths(config) {
134134
function normalizeURLs(config) {
135135
var basePath = config.basePath.replace(/^\/*/, '/').replace(/\/*$/, '');
136136
var assetPath = config.assetPath.replace(/(^\/*|\/*$)/g, '');
137+
var workerPath = config.workerPath.replace(/^\/*/, '/');
138+
137139
return Object.assign({}, config, {
138140
locations: config.locations
139141
.map(function(location) {
@@ -144,6 +146,7 @@ function normalizeURLs(config) {
144146
}),
145147
basePath: basePath,
146148
assetPath: assetPath,
149+
workerPath: workerPath,
147150
});
148151
}
149152

packages/pwa/dom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = function installServiceWorker() {
1515
window.location.hostname === 'localhost'
1616
) {
1717
window.addEventListener('load', function() {
18-
resolve(navigator.serviceWorker.register('/' + hopsConfig.workerPath));
18+
resolve(navigator.serviceWorker.register(hopsConfig.workerPath));
1919
});
2020
}
2121
});

0 commit comments

Comments
 (0)