robinvdvleuten / vuex-persistedstate

💾 Persist and rehydrate your Vuex state between page reloads.
https://npm.im/vuex-persistedstate
MIT License
5.76k stars 375 forks source link

Prevent JSON.parse to be called with a non string value #400

Closed joaoaraujo-hotmart closed 2 years ago

joaoaraujo-hotmart commented 3 years ago

What: Prevent JSON.parse to be called with a non string value

Why: Sometimes (non standard storages) the item provided by getItem method is already of Object type.

How: In general, JSON parse needs to be called with a string parameter, if this is satisfied, do it. If not, check if it is already a Object, and if it is, return it. Otherwise, return undefined.

Checklist:

NorseGaud commented 2 years ago

Bump

robinvdvleuten commented 2 years ago

@joaoaraujo-hotmart could you please add some test cases?

robinvdvleuten commented 2 years ago

@all-contributors please add @joaoaraujo-hotmart for code

allcontributors[bot] commented 2 years ago

@robinvdvleuten

I've put up a pull request to add @joaoaraujo-hotmart! :tada: