Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

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

Merged

Conversation

joaoaraujo-hotmart
Copy link
Contributor

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:

  • [N/A] Documentation
  • Tests
  • Ready to be merged
  • Added myself to contributors table

@NorseGaud
Copy link

Bump

@robinvdvleuten
Copy link
Owner

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

@robinvdvleuten robinvdvleuten merged commit 6b5c2db into robinvdvleuten:master Sep 21, 2021
@robinvdvleuten
Copy link
Owner

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

@allcontributors
Copy link
Contributor

@robinvdvleuten

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants