Skip to content

Commit

Permalink
Merge pull request #51 from ipld/string_fix
Browse files Browse the repository at this point in the history
fix: support all forms of json
  • Loading branch information
daviddias authored Apr 4, 2017
2 parents c6f7c18 + f179108 commit 6b14373
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ const decoder = new cbor.Decoder({
})

function replaceCIDbyTAG (dagNode) {
if (isCircular(dagNode)) {
let circular
try {
circular = isCircular(dagNode)
} catch (e) {
circular = false
}
if (circular) {
throw new Error('The object passed has circular references')
}

Expand Down
10 changes: 10 additions & 0 deletions test/util.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ describe('util', () => {
})
})

it('strings', (done) => {
dagCBOR.util.cid('some test string', (err, cid) => {
expect(err).to.not.exist()
expect(cid.version).to.equal(1)
expect(cid.codec).to.equal('dag-cbor')
expect(cid.multihash).to.exist()
done()
})
})

it.skip('serialize and deserialize - garbage', (done) => {
const inputs = []

Expand Down

0 comments on commit 6b14373

Please sign in to comment.