Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Catch errors from JSON.parse #107

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix: Catch errors from JSON.parse #107

wants to merge 2 commits into from

Conversation

glensc
Copy link

@glensc glensc commented Feb 6, 2023

By submitting a PR to this repository, you agree to the terms within the Auth0 Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.

Description

Keep the contract that the decode returns null on errors

➜ node
Welcome to Node.js v16.19.0.
Fix: Catch errors from JSON.parse
Type ".help" for more information.
> JSON.parse("xx")
Uncaught SyntaxError: Unexpected token x in JSON at position 0
>

Checklist

  • This change adds test coverage for new/changed/fixed functionality
  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not the default branch

Keep the contract that the decode returns null on errors
> reviver Optional
>
> If a function, this prescribes how each value originally produced by
> parsing is transformed before being returned. Non-callable values are
> ignored. The function is called with the following arguments:

- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse
@glensc
Copy link
Author

glensc commented Feb 6, 2023

Includes #108, depends which one gets merged first.

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

Successfully merging this pull request may close these issues.

1 participant