Skip to content

Commit

Permalink
refactor(service-worker): make second parameter to `Adapter#parseUrl(…
Browse files Browse the repository at this point in the history
…)` optional (#27080)

PR Close #27080
  • Loading branch information
gkalpak authored and matsko committed Mar 21, 2019
1 parent 41737bb commit b3dda0e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/service-worker/worker/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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};
}
Expand Down
3 changes: 1 addition & 2 deletions packages/service-worker/worker/src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<UpdateCacheStatus> {
Expand Down
2 changes: 1 addition & 1 deletion packages/service-worker/worker/testing/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit b3dda0e

Please sign in to comment.