Sfoglia il codice sorgente

uppyOptions might be undefined, catch JSON.parse error

Artur Paikin 7 anni fa
parent
commit
35a73286e1
1 ha cambiato i file con 6 aggiunte e 1 eliminazioni
  1. 6 1
      website/src/examples/dashboard/app.html

+ 6 - 1
website/src/examples/dashboard/app.html

@@ -42,7 +42,12 @@
   }
   }
 
 
   // try to get options from localStorage, if its empty, set to defaultOpts
   // try to get options from localStorage, if its empty, set to defaultOpts
-  window.uppyOptions = JSON.parse(localStorage.getItem('uppyOptions')) || {}
+  try {
+    window.uppyOptions = JSON.parse(localStorage.getItem('uppyOptions')) || {}
+  } catch (err) {
+    window.uppyOptions = {}
+  }
+  
   if (isObjEmpty(window.uppyOptions)) {
   if (isObjEmpty(window.uppyOptions)) {
     window.uppyOptions = defaultOpts
     window.uppyOptions = defaultOpts
     localStorage.setItem('uppyOptions', JSON.stringify(window.uppyOptions))
     localStorage.setItem('uppyOptions', JSON.stringify(window.uppyOptions))