Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viewer: dont check file type, try to parse json file. Fixes #1204 #1234

Merged
merged 1 commit into from
Dec 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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