Skip to content

Commit

Permalink
Viewer: dont check file type, try to parse json file (#1234)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebidel authored and brendankenny committed Dec 22, 2016
1 parent a00240b commit c5402c9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lighthouse-viewer/app/src/lighthouse-report-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,16 @@ class LighthouseViewerReport {
*/
onFileUpload(file) {
return FileUploader.readFile(file).then(str => {
if (!file.type.match('json')) {
throw new Error('Unsupported report format. Expected JSON.');
let json;
try {
json = JSON.parse(str);
} catch(e) {
throw new Error('Could not parse JSON file.');
}

this._isNewReport = true;

this.replaceReportHTML(JSON.parse(str));
this.replaceReportHTML(json);
}).catch(err => logger.error(err.message));
}

Expand Down

0 comments on commit c5402c9

Please sign in to comment.