Skip to content

Fix: Catch errors from JSON.parse#107

Open
glensc wants to merge 2 commits intoauth0:masterfrom
glensc:f
Open

Fix: Catch errors from JSON.parse#107
glensc wants to merge 2 commits intoauth0:masterfrom
glensc:f

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

1 participant