Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
fix: don't throw if it's not a proper old-style link
Browse files Browse the repository at this point in the history
We are still supporting old style links, i.e. JSON where `/` as key
signals a link. Though the JSON could could also contain such a key
without having a CID as value. Instead of throwing an error, treat it
as not being a link.
  • Loading branch information
vmx committed Mar 21, 2019
1 parent 79e521c commit 38be898
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ class IPLDResolver {
// NOTE vmx 2018-11-29: Not all IPLD Formats return links as
// CIDs yet. Hence try to convert old style links to CIDs
if (Object.keys(value).length === 1 && '/' in value) {
value = new CID(value['/'])
try {
value = new CID(value['/'])
} catch (_error) {
value = null
}
}
cid = CID.isCID(value) ? value : null

Expand Down

0 comments on commit 38be898

Please sign in to comment.