Skip to content

Commit

Permalink
update build
Browse files Browse the repository at this point in the history
  • Loading branch information
pldespaigne committed Nov 19, 2019
1 parent ca2c6d9 commit 332763c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5933,17 +5933,20 @@ module.exports = function (value) {
const CID = require('cids');

/**
* Take an ipfsHash and convert it to a CID v1 encoded in base32.
* Take any ipfsHash and convert it to a CID v1 encoded in base32.
* @param {string} ipfsHash a regular ipfs hash either a cid v0 or v1 (v1 will remain unchanged)
* @return {string} the resulting ipfs hash as a cid v1
*/
const cidV0ToV1Base32 = (ipfsHash) => {
const cidV0 = new CID(ipfsHash);
const cidV1Base32 = new CID(1, 'dag-pb', cidV0.multihash, 'base32');
return cidV1Base32.toString();
let cid = new CID(ipfsHash);
if (cid.version === 0) {
cid = cid.toV1();
}
return cid.toString('base32');
}

exports.cidV0ToV1Base32 = cidV0ToV1Base32;

},{"cids":6}],31:[function(require,module,exports){
/*
ISC License
Expand Down

0 comments on commit 332763c

Please sign in to comment.