Skip to content

Commit d6f6f93

Browse files
brabojclaude
andcommitted
fix: handle missing URL fields in Lighthouse report parsing
Use finalDisplayedUrl as primary, fall back to finalUrl, requestedUrl, then filename. Guard against non-http values. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 721437f commit d6f6f93

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

.github/workflows/lighthouse.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,16 @@ jobs:
4949
const files = fs.readdirSync(dir).filter(f => f.endsWith('.json') && !f.startsWith('manifest'));
5050
const rows = files.map(f => {
5151
const r = JSON.parse(fs.readFileSync(path.join(dir, f), 'utf8'));
52-
const url = new URL(r.finalUrl || r.requestedUrl);
52+
const rawUrl = r.finalDisplayedUrl || r.finalUrl || r.requestedUrl || '';
53+
const pagePath = rawUrl.startsWith('http') ? new URL(rawUrl).pathname : rawUrl || f;
5354
const scores = r.categories;
5455
const fmt = (cat) => {
5556
if (!scores[cat]) return 'N/A';
5657
const s = Math.round(scores[cat].score * 100);
5758
const icon = s >= 90 ? '🟢' : s >= 50 ? '🟠' : '🔴';
5859
return `${icon} ${s}`;
5960
};
60-
return `| ${url.pathname} | ${fmt('performance')} | ${fmt('accessibility')} | ${fmt('best-practices')} | ${fmt('seo')} |`;
61+
return `| ${pagePath} | ${fmt('performance')} | ${fmt('accessibility')} | ${fmt('best-practices')} | ${fmt('seo')} |`;
6162
});
6263
const body = [
6364
'## Lighthouse Results',

0 commit comments

Comments
 (0)