Skip to content
This repository has been archived by the owner on Aug 12, 2020. It is now read-only.

Commit

Permalink
Use multihashes for sanitization.
Browse files Browse the repository at this point in the history
  • Loading branch information
hackergrrl committed Aug 4, 2016
1 parent 3df6167 commit 641a8a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"aegir": "^4.0.0",
"async": "^1.5.2",
"block-stream2": "^1.1.0",
"bs58": "^3.0.0",
"buffer-loader": "0.0.1",
"chai": "^3.5.0",
"concat-stream": "^1.5.1",
Expand All @@ -61,6 +60,7 @@
"ipfs-unixfs": "^0.1.0",
"is-ipfs": "^0.2.0",
"isstream": "^0.1.2",
"multihashes": "^0.2.2",
"readable-stream": "^1.1.13",
"run-series": "^1.1.4",
"streamifier": "^0.1.1",
Expand Down
4 changes: 2 additions & 2 deletions src/clean-multihash.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict'

const bs58 = require('bs58')
const mh = require('multihashes')
const isIPFS = require('is-ipfs')

module.exports = function (multihash) {
if (!isIPFS.multihash(multihash)) {
throw new Error('not valid multihash')
}
if (Buffer.isBuffer(multihash)) {
return bs58.encode(multihash)
return mh.toB58String(multihash)
}
return multihash
}

0 comments on commit 641a8a1

Please sign in to comment.