Merge pull request #394 from mozilla/i393

catch JSON.parse errors of storage metadata
This commit is contained in:
Danny Coates 2017-08-02 12:28:55 -07:00 committed by GitHub
commit 5b9e9d5146
2 changed files with 7 additions and 7 deletions

View File

@ -29,7 +29,12 @@ class Storage {
for (let i = 0; i < this.engine.length; i++) {
const k = this.engine.key(i);
if (isFile(k)) {
fs.push(JSON.parse(this.engine.getItem(k))); // parse or whatever else
try {
fs.push(JSON.parse(this.engine.getItem(k)));
} catch (err) {
// obviously you're not a golfer
this.engine.removeItem(k);
}
}
}
return fs.sort((file1, file2) => {

View File

@ -99,12 +99,7 @@ function findMetric(href) {
}
function isFile(id) {
return ![
'referrer',
'totalDownloads',
'totalUploads',
'testpilot_ga__cid'
].includes(id);
return /^[0-9a-fA-F]{10}$/.test(id);
}
function sendEvent() {