This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 3 files changed +19
-4
lines changed
3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
3
const promisify = require ( 'promisify-es6' )
4
- const cleanMultihash = require ( '../clean-multihash ' )
4
+ const cleanCID = require ( '../clean-cid ' )
5
5
6
6
module . exports = ( send ) => {
7
7
return promisify ( ( hash , opts , callback ) => {
@@ -11,7 +11,7 @@ module.exports = (send) => {
11
11
}
12
12
13
13
try {
14
- hash = cleanMultihash ( hash )
14
+ hash = cleanCID ( hash )
15
15
} catch ( err ) {
16
16
return callback ( err )
17
17
}
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
3
const promisify = require ( 'promisify-es6' )
4
- const cleanMultihash = require ( '../clean-multihash ' )
4
+ const cleanCID = require ( '../clean-cid ' )
5
5
const TarStreamToObjects = require ( '../tar-stream-to-objects' )
6
6
7
7
module . exports = ( send ) => {
@@ -21,7 +21,7 @@ module.exports = (send) => {
21
21
}
22
22
23
23
try {
24
- path = cleanMultihash ( path )
24
+ path = cleanCID ( path )
25
25
} catch ( err ) {
26
26
return callback ( err )
27
27
}
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