Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 026a542

Browse files
fix: typeof bug when passing timeout to dag.get (#3035)
Passing `options` without a `path` to dag.get will throw an error. ``` ipfs.dag.get(cidPath, { timeout: 2000 }) TypeError: Cannot read property 'timeout' of null ``` Cause by the lovely JS issue of `typeof null === 'object'`. Co-authored-by: Kia Rahimian <[email protected]>
1 parent 3e4a716 commit 026a542

File tree

2 files changed

+6
-1
lines changed
  • packages
    • interface-ipfs-core/src/dag
    • ipfs-http-client/src/dag

2 files changed

+6
-1
lines changed

packages/interface-ipfs-core/src/dag/get.js

+5
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ module.exports = (common, options) => {
147147
expect(result.value.equals(cidPb)).to.be.true()
148148
})
149149

150+
it('should get with options and no path', async function () {
151+
const result = await ipfs.dag.get(cidCbor, { localResolve: true })
152+
expect(result.value).to.deep.equal(nodeCbor)
153+
})
154+
150155
it('should get a node added as CIDv0 with a CIDv1', async () => {
151156
const input = Buffer.from(`TEST${Math.random()}`)
152157

packages/ipfs-http-client/src/dag/get.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = configure((api, options) => {
1616
const dagResolve = require('./resolve')(options)
1717

1818
return async (cid, path, options = {}) => {
19-
if (typeof path === 'object') {
19+
if (path && typeof path === 'object') {
2020
options = path
2121
path = null
2222
}

0 commit comments

Comments
 (0)