MatrixAI / js-id

ID generation for JavaScript & TypeScript Applications
https://polykey.com
Apache License 2.0
10 stars 1 forks source link

Patch for fromMultibase error on non-multibase strings #15

Closed emmacasolin closed 2 years ago

emmacasolin commented 2 years ago

Description

The fromMultibase() utility was throwing an error on plain string/non-multibase inputs, when it should instead have been returning undefined. The line this was coming from, codec.decode(), has now been warpped in a try-catch block in order to return undefined on this error, as is the expected behaviour.

Previously a fix was pushed to only catch Syntax Errors, however this was insufficient and instead all errors should be caught,

Tasks

  1. [x] Modify the catch handler on codec.decode() to return on all errors
  2. [x] Update utils tests to cover missed cases

Final checklist