lighthouse 11.3.0-dev.20231130 → 11.3.0-dev.20231202
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/audits/byte-efficiency/byte-efficiency-audit.d.ts +14 -0
- package/core/audits/byte-efficiency/byte-efficiency-audit.js +60 -0
- package/core/audits/byte-efficiency/legacy-javascript.d.ts +6 -4
- package/core/audits/byte-efficiency/legacy-javascript.js +21 -18
- package/core/computed/entity-classification.js +1 -1
- package/core/computed/resource-summary.d.ts +0 -1
- package/core/computed/resource-summary.js +2 -2
- package/core/gather/navigation-runner.js +1 -1
- package/core/lib/network-recorder.d.ts +8 -0
- package/core/lib/network-recorder.js +13 -0
- package/core/lib/network-request.d.ts +11 -0
- package/core/lib/network-request.js +18 -1
- package/core/lib/url-utils.d.ts +6 -0
- package/core/lib/url-utils.js +14 -2
- package/core/scripts/download-chrome.sh +54 -16
- package/dist/report/bundle.esm.js +4 -4
- package/dist/report/flow.js +2 -2
- package/dist/report/standalone.js +5 -5
- package/package.json +2 -1
- package/report/renderer/report-ui-features.js +3 -2
- package/shared/util.d.ts +14 -2
- package/shared/util.js +25 -3
package/shared/util.js
CHANGED
|
@@ -77,6 +77,23 @@ class Util {
|
|
|
77
77
|
return details;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Given the entity classification dataset and a URL, identify the entity.
|
|
82
|
+
* @param {string} url
|
|
83
|
+
* @param {LH.Result.Entities=} entities
|
|
84
|
+
* @return {LH.Result.LhrEntity|string}
|
|
85
|
+
*/
|
|
86
|
+
static getEntityFromUrl(url, entities) {
|
|
87
|
+
// If it's a pre-v10 LHR, we don't have entities, so match against the root-ish domain
|
|
88
|
+
if (!entities) {
|
|
89
|
+
return Util.getPseudoRootDomain(url);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const entity = entities.find(e => e.origins.find(origin => url.startsWith(origin)));
|
|
93
|
+
// This fallback case would be unexpected, but leaving for safety.
|
|
94
|
+
return entity || Util.getPseudoRootDomain(url);
|
|
95
|
+
}
|
|
96
|
+
|
|
80
97
|
/**
|
|
81
98
|
* Split a string by markdown code spans (enclosed in `backticks`), splitting
|
|
82
99
|
* into segments that were enclosed in backticks (marked as `isCode === true`)
|
|
@@ -292,11 +309,12 @@ class Util {
|
|
|
292
309
|
|
|
293
310
|
/**
|
|
294
311
|
* Gets the tld of a domain
|
|
312
|
+
* This function is used only while rendering pre-10.0 LHRs.
|
|
295
313
|
*
|
|
296
314
|
* @param {string} hostname
|
|
297
315
|
* @return {string} tld
|
|
298
316
|
*/
|
|
299
|
-
static
|
|
317
|
+
static getPseudoTld(hostname) {
|
|
300
318
|
const tlds = hostname.split('.').slice(-2);
|
|
301
319
|
|
|
302
320
|
if (!listOfTlds.includes(tlds[0])) {
|
|
@@ -308,12 +326,16 @@ class Util {
|
|
|
308
326
|
|
|
309
327
|
/**
|
|
310
328
|
* Returns a primary domain for provided hostname (e.g. www.example.com -> example.com).
|
|
329
|
+
* As it doesn't consult the Public Suffix List, it can sometimes lose detail.
|
|
330
|
+
* See the `listOfTlds` comment above for more.
|
|
331
|
+
* This function is used only while rendering pre-10.0 LHRs. See UrlUtils.getRootDomain
|
|
332
|
+
* for the current method that makes use of PSL.
|
|
311
333
|
* @param {string|URL} url hostname or URL object
|
|
312
334
|
* @return {string}
|
|
313
335
|
*/
|
|
314
|
-
static
|
|
336
|
+
static getPseudoRootDomain(url) {
|
|
315
337
|
const hostname = Util.createOrReturnURL(url).hostname;
|
|
316
|
-
const tld = Util.
|
|
338
|
+
const tld = Util.getPseudoTld(hostname);
|
|
317
339
|
|
|
318
340
|
// tld is .com or .co.uk which means we means that length is 1 to big
|
|
319
341
|
// .com => 2 & .co.uk => 3
|