Skip to content

Commit

Permalink
fix: typeof bug when passing timeout to dag.get (#3035)
Browse files Browse the repository at this point in the history
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 <kia@tintmail.com>
  • Loading branch information
achingbrain and mistakia authored May 14, 2020
1 parent 41bdf44 commit 7156387
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/dag/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = configure((api, options) => {
const dagResolve = require('./resolve')(options)

return async (cid, path, options = {}) => {
if (typeof path === 'object') {
if (path && typeof path === 'object') {
options = path
path = null
}
Expand Down

0 comments on commit 7156387

Please sign in to comment.