Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianaixba committed Aug 28, 2020
1 parent 29ed8f3 commit 84e09b6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lighthouse-core/audits/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ServiceWorker extends Audit {
*/
static getControllingServiceWorker(matchingSWVersions, registrations, pageUrl) {
// Find the normalized scope URLs of possibly-controlling SWs.
/** @type {Array<{ scopeUrl: string; scriptUrl: string;}>} */
/** @type {Array<{scopeUrl: string; scriptUrl: string}>} */
const scriptByScopeUrlList = [];

// Populate serviceWorkerUrls map with the scriptURLs and scopeUrls of matchingSWVersions and registrations
Expand All @@ -95,8 +95,8 @@ class ServiceWorker extends Audit {
// Find most-specific applicable scope, the one controlling the page.
// See https://w3c.github.io/ServiceWorker/v1/#scope-match-algorithm
const pageControllingUrls = scriptByScopeUrlList
.filter(urlPair => pageUrl.href.startsWith(urlPair.scopeUrl.toString()))
.sort((scopeA, scopeB) => scopeA.scopeUrl.length - scopeB.scopeUrl.length)
.filter(ss => pageUrl.href.startsWith(ss.scopeUrl))
.sort((ssA, ssB) => ssA.scopeUrl.length - ssB.scopeUrl.length)
.pop();

return pageControllingUrls;
Expand Down

0 comments on commit 84e09b6

Please sign in to comment.