catch JSON.parse errors of storage metadata
This commit is contained in:
parent
f1c894d14f
commit
2897a39131
@ -29,7 +29,12 @@ class Storage {
|
|||||||
for (let i = 0; i < this.engine.length; i++) {
|
for (let i = 0; i < this.engine.length; i++) {
|
||||||
const k = this.engine.key(i);
|
const k = this.engine.key(i);
|
||||||
if (isFile(k)) {
|
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) => {
|
return fs.sort((file1, file2) => {
|
||||||
|
@ -99,12 +99,7 @@ function findMetric(href) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isFile(id) {
|
function isFile(id) {
|
||||||
return ![
|
return /^[0-9a-fA-F]{10}$/.test(id);
|
||||||
'referrer',
|
|
||||||
'totalDownloads',
|
|
||||||
'totalUploads',
|
|
||||||
'testpilot_ga__cid'
|
|
||||||
].includes(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendEvent() {
|
function sendEvent() {
|
||||||
|
Loading…
Reference in New Issue
Block a user