Skip to content

Commit

Permalink
Remove spurious AppSubUrl in serviceworker request. (go-gitea#16047)
Browse files Browse the repository at this point in the history
There is another spurious AppSubUrl placement in the serviceworker registration.
This PR removes it.

Signed-off-by: Andrew Thornton <art27@cantab.net>
  • Loading branch information
zeripath authored Jun 8, 2021
1 parent 44f8c81 commit e03a91a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions web_src/js/features/serviceworker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {joinPaths} from '../utils.js';

const {UseServiceWorker, AppSubUrl, AssetUrlPrefix, AppVer} = window.config;
const {UseServiceWorker, AssetUrlPrefix, AppVer} = window.config;
const cachePrefix = 'static-cache-v'; // actual version is set in the service worker script
const workerAssetPath = joinPaths(AssetUrlPrefix, 'serviceworker.js');

Expand Down Expand Up @@ -41,10 +41,9 @@ export default async function initServiceWorker() {
// unregister all service workers where scriptURL does not match the current one
await unregisterOtherWorkers();
try {
// normally we'd serve the service worker as a static asset from AssetUrlPrefix but
// the spec strictly requires it to be same-origin so it has to be AppSubUrl to work
// the spec strictly requires it to be same-origin so the AssetUrlPrefix should contain AppSubUrl
await checkCacheValidity();
await navigator.serviceWorker.register(joinPaths(AppSubUrl, workerAssetPath));
await navigator.serviceWorker.register(workerAssetPath);
} catch (err) {
console.error(err);
await invalidateCache();
Expand Down

0 comments on commit e03a91a

Please sign in to comment.