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

Commit cc9a933

Browse files
author
Alan Shaw
committed
fix: block put with CID as string (#2760)
* fix: block put with CID as string * chore: update interface-ipfs-core dep
1 parent eb33a63 commit cc9a933

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
"form-data": "^3.0.0",
185185
"go-ipfs-dep": "^0.4.23",
186186
"hat": "0.0.3",
187-
"interface-ipfs-core": "^0.131.7",
187+
"interface-ipfs-core": "^0.132.0",
188188
"ipfs-interop": "github:ipfs/interop#refactor/async-await",
189189
"ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#remove-option-normalisation",
190190
"ncp": "^2.0.0",

src/core/components/block/put.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const Block = require('ipfs-block')
44
const multihashing = require('multihashing-async')
55
const CID = require('cids')
6+
const isIPFS = require('is-ipfs')
67

78
module.exports = ({ blockService, gcLock, preload }) => {
89
return async function put (block, options) {
@@ -13,8 +14,8 @@ module.exports = ({ blockService, gcLock, preload }) => {
1314
}
1415

1516
if (!Block.isBlock(block)) {
16-
if (options.cid && CID.isCID(options.cid)) {
17-
block = new Block(block, options.cid)
17+
if (options.cid && isIPFS.cid(options.cid)) {
18+
block = new Block(block, CID.isCID(options.cid) ? options.cid : new CID(options.cid))
1819
} else {
1920
const mhtype = options.mhtype || 'sha2-256'
2021
const format = options.format || 'dag-pb'

0 commit comments

Comments
 (0)