diff --git a/packages/service-worker/worker/src/adapter.ts b/packages/service-worker/worker/src/adapter.ts index dfd30be040..2e2847d62e 100644 --- a/packages/service-worker/worker/src/adapter.ts +++ b/packages/service-worker/worker/src/adapter.ts @@ -43,7 +43,7 @@ export class Adapter { /** * Extract the pathname of a URL. */ - parseUrl(url: string, relativeTo: string): {origin: string, path: string} { + parseUrl(url: string, relativeTo?: string): {origin: string, path: string} { const parsed = new URL(url, relativeTo); return {origin: parsed.origin, path: parsed.pathname}; } diff --git a/packages/service-worker/worker/src/assets.ts b/packages/service-worker/worker/src/assets.ts index 8776eb1973..19843818f3 100644 --- a/packages/service-worker/worker/src/assets.ts +++ b/packages/service-worker/worker/src/assets.ts @@ -69,8 +69,7 @@ export abstract class AssetGroup { // Determine the origin from the registration scope. This is used to differentiate between // relative and absolute URLs. - this.origin = - this.adapter.parseUrl(this.scope.registration.scope, this.scope.registration.scope).origin; + this.origin = this.adapter.parseUrl(this.scope.registration.scope).origin; } async cacheStatus(url: string): Promise { diff --git a/packages/service-worker/worker/testing/scope.ts b/packages/service-worker/worker/testing/scope.ts index f357f4da41..265df3c3d6 100644 --- a/packages/service-worker/worker/testing/scope.ts +++ b/packages/service-worker/worker/testing/scope.ts @@ -175,7 +175,7 @@ export class SwTestHarness implements ServiceWorkerGlobalScope, Adapter, Context }, new MockHeaders()); } - parseUrl(url: string, relativeTo: string): {origin: string, path: string} { + parseUrl(url: string, relativeTo?: string): {origin: string, path: string} { if (typeof URL === 'function') { const obj = new URL(url, relativeTo); return {origin: obj.origin, path: obj.pathname};