mirror of
https://github.com/DeNNiiInc/Web-Page-Performance-Test.git
synced 2026-04-17 20:05:58 +00:00
Fix runner.js - even safer property access
This commit is contained in:
@@ -154,13 +154,13 @@ async function _executeTest(url, options) {
|
||||
|
||||
|
||||
// Safe property access
|
||||
const getScore = (cat) => (lhr.categories[cat] && lhr.categories[cat].score) ? lhr.categories[cat].score * 100 : 0;
|
||||
const getMetric = (aud) => (lhr.audits[aud] && lhr.audits[aud].numericValue) ? lhr.audits[aud].numericValue : 0;
|
||||
const getScore = (cat) => (lhr.categories && lhr.categories[cat] && lhr.categories[cat].score) ? lhr.categories[cat].score * 100 : 0;
|
||||
const getMetric = (aud) => (lhr.audits && lhr.audits[aud] && lhr.audits[aud].numericValue) ? lhr.audits[aud].numericValue : 0;
|
||||
|
||||
const summary = {
|
||||
id: testId,
|
||||
url: lhr.finalUrl,
|
||||
timestamp: lhr.fetchTime,
|
||||
url: lhr.finalUrl || url,
|
||||
timestamp: lhr.fetchTime || new Date().toISOString(),
|
||||
scores: {
|
||||
performance: getScore('performance'),
|
||||
accessibility: getScore('accessibility'),
|
||||
@@ -225,8 +225,8 @@ async function _executeTest(url, options) {
|
||||
|
||||
const summary = {
|
||||
id: testId,
|
||||
url: lhr.finalUrl,
|
||||
timestamp: lhr.fetchTime,
|
||||
url: lhr.finalUrl || url,
|
||||
timestamp: lhr.fetchTime || new Date().toISOString(),
|
||||
scores: {
|
||||
performance: getScore('performance'),
|
||||
accessibility: getScore('accessibility'),
|
||||
|
||||
Reference in New Issue
Block a user