Skip to content

Commit

Permalink
core(valid-source-maps): validate url in first-party check (#14758)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexnj authored Feb 7, 2023
1 parent 860d7bf commit 5d31531
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions core/audits/valid-source-maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import {Audit} from './audit.js';
import {EntityClassification} from '../computed/entity-classification.js';
import * as i18n from '../lib/i18n/i18n.js';
import {Util} from '../../shared/util.js';
import UrlUtils from '../lib/url-utils.js';

const UIStrings = {
/** Title of a Lighthouse audit that provides detail on HTTP to HTTPS redirects. This descriptive title is shown to users when HTTP traffic is redirected to HTTPS. */
Expand Down Expand Up @@ -54,11 +56,13 @@ class ValidSourceMaps extends Audit {
* @return {boolean}
*/
static isLargeFirstPartyJS(script, classifiedEntities) {
if (!script.length) return false;
const url = script.url;
if (!script.length || !url) return false;
if (!UrlUtils.isValid(url)) return false;
if (!Util.createOrReturnURL(url).protocol.startsWith('http')) return false;

const isLargeJS = script.length >= LARGE_JS_BYTE_THRESHOLD;
const isFirstPartyJS = script.url ? classifiedEntities.isFirstParty(script.url) : false;
return isLargeJS && isFirstPartyJS;
return classifiedEntities.isFirstParty(url) && isLargeJS;
}

/**
Expand Down

0 comments on commit 5d31531

Please sign in to comment.