Преглед изворни кода

Fixed persist crash when the stored value is undefined (#4091)

* Fixed persist crash when the stored value is undefined

Fixed persist crash when the stored value is undefined.
This bug crashes Alpine

* refactor

---------

Co-authored-by: Caleb Porzio <calebporzio@gmail.com>
Alwahibi пре 1 година
родитељ
комит
c38a45f3b6
1 измењених фајлова са 5 додато и 1 уклоњено
  1. 5 1
      packages/persist/src/index.js

+ 5 - 1
packages/persist/src/index.js

@@ -65,7 +65,11 @@ function storageHas(key, storage) {
 }
 
 function storageGet(key, storage) {
-    return JSON.parse(storage.getItem(key, storage))
+    let value = storage.getItem(key, storage)
+
+    if (value === undefined) return
+
+    return JSON.parse(value)
 }
 
 function storageSet(key, value, storage) {