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

Commit 38be898

Browse files
committed
fix: don't throw if it's not a proper old-style link
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.
1 parent 79e521c commit 38be898

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ class IPLDResolver {
109109
// NOTE vmx 2018-11-29: Not all IPLD Formats return links as
110110
// CIDs yet. Hence try to convert old style links to CIDs
111111
if (Object.keys(value).length === 1 && '/' in value) {
112-
value = new CID(value['/'])
112+
try {
113+
value = new CID(value['/'])
114+
} catch (_error) {
115+
value = null
116+
}
113117
}
114118
cid = CID.isCID(value) ? value : null
115119

0 commit comments

Comments
 (0)