Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(valid-source-maps): validate url in first-party check #14758

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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