Skip to content

Commit

Permalink
Fixed persist crash when the stored value is undefined (#4091)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
wahibimoh and calebporzio committed Mar 18, 2024
1 parent 44a8762 commit c38a45f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/persist/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c38a45f

Please sign in to comment.