This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 11'use strict'
22
33const promisify = require ( 'promisify-es6' )
4- const cleanMultihash = require ( '../clean-multihash ' )
4+ const cleanCID = require ( '../clean-cid ' )
55
66module . exports = ( send ) => {
77 return promisify ( ( hash , opts , callback ) => {
@@ -11,7 +11,7 @@ module.exports = (send) => {
1111 }
1212
1313 try {
14- hash = cleanMultihash ( hash )
14+ hash = cleanCID ( hash )
1515 } catch ( err ) {
1616 return callback ( err )
1717 }
Original file line number Diff line number Diff line change 11'use strict'
22
33const promisify = require ( 'promisify-es6' )
4- const cleanMultihash = require ( '../clean-multihash ' )
4+ const cleanCID = require ( '../clean-cid ' )
55const TarStreamToObjects = require ( '../tar-stream-to-objects' )
66
77module . exports = ( send ) => {
@@ -21,7 +21,7 @@ module.exports = (send) => {
2121 }
2222
2323 try {
24- path = cleanMultihash ( path )
24+ path = cleanCID ( path )
2525 } catch ( err ) {
2626 return callback ( err )
2727 }
Original file line number Diff line number Diff line change 1+ 'use strict'
2+
3+ const bs58 = require ( 'bs58' )
4+ const CID = require ( 'cids' )
5+
6+ module . exports = function ( cid ) {
7+ if ( Buffer . isBuffer ( cid ) ) {
8+ cid = bs58 . encode ( cid )
9+ }
10+ if ( typeof cid !== 'string' ) {
11+ throw new Error ( 'unexpected cid type: ' + typeof cid )
12+ }
13+ CID . validateCID ( new CID ( cid . split ( '/' ) [ 0 ] ) )
14+ return cid
15+ }
You can’t perform that action at this time.
0 commit comments