From 520f9ac06420634ccc03d0326e8e42fe83610a42 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 24 May 2018 12:05:58 -0700 Subject: [PATCH] misc(viewer): load *.json if no *.lighthouse.report.json (#5343) --- lighthouse-viewer/app/src/github-api.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lighthouse-viewer/app/src/github-api.js b/lighthouse-viewer/app/src/github-api.js index 21b3939f7091..a6b846decb60 100644 --- a/lighthouse-viewer/app/src/github-api.js +++ b/lighthouse-viewer/app/src/github-api.js @@ -115,9 +115,13 @@ class GithubApi { const etag = resp.headers.get('ETag'); return resp.json().then(json => { + const gistFiles = Object.keys(json.files); // Attempt to use first file in gist with report extension. - const filename = Object.keys(json.files) - .find(filename => filename.endsWith(GithubApi.LH_JSON_EXT)); + let filename = gistFiles.find(filename => filename.endsWith(GithubApi.LH_JSON_EXT)); + // Otherwise, fall back to first json file in gist + if (!filename) { + filename = gistFiles.find(filename => filename.endsWith('.json')); + } if (!filename) { throw new Error( `Failed to find a Lighthouse report (*${GithubApi.LH_JSON_EXT}) in gist ${id}`