@@ -6,8 +6,7 @@ const reduce = require('async/reduce')
66const CID = require ( 'cids' )
77const Unixfs = require ( 'ipfs-unixfs' )
88const debug = require ( 'debug' )
9- const log = debug ( 'jsipfs:http:response:resolver' )
10- log . error = debug ( 'jsipfs:http:response:resolver:error' )
9+ const log = debug ( 'ipfs:http:response:resolver' )
1110
1211const dirView = require ( './dir-view' )
1312const pathUtil = require ( './utils/path' )
@@ -19,13 +18,13 @@ function getIndexFiles (links) {
1918 'index.shtml'
2019 ]
2120 // directory
22- let indexes = links . filter ( ( link ) => INDEX_HTML_FILES . indexOf ( link . name ) !== - 1 )
21+ let indexes = links . filter ( ( link ) => INDEX_HTML_FILES . indexOf ( link . Name ) !== - 1 )
2322 if ( indexes . length ) {
2423 return indexes
2524 }
2625 // hamt-sharded-directory uses a 2 char prefix
2726 return links . filter ( ( link ) => {
28- return link . name . length > 2 && INDEX_HTML_FILES . indexOf ( link . name . substring ( 2 ) ) !== - 1
27+ return link . Name . length > 2 && INDEX_HTML_FILES . indexOf ( link . Name . substring ( 2 ) ) !== - 1
2928 } )
3029}
3130
@@ -38,13 +37,13 @@ const directory = promisify((ipfs, path, cid, callback) => {
3837 }
3938
4039 // Test if it is a Website
41- const indexFiles = getIndexFiles ( dagNode . links )
40+ const indexFiles = getIndexFiles ( dagNode . Links )
4241
4342 if ( indexFiles . length ) {
4443 return callback ( null , indexFiles )
4544 }
4645
47- return callback ( null , dirView . render ( path , dagNode . links ) )
46+ return callback ( null , dirView . render ( path , dagNode . Links ) )
4847 } )
4948} )
5049
@@ -80,17 +79,9 @@ const cid = promisify((ipfs, path, callback) => {
8079 const nextFileName = item
8180
8281 try {
83- for ( let link of dagNode . links ) {
84- if ( link . name === nextFileName ) {
85- // found multihash/cid of requested named-file
86- try {
87- // assume a Buffer with a valid CID
88- // (cid is allowed instead of multihash since https://github.com/ipld/js-ipld-dag-pb/pull/80)
89- cidOfNextFile = new CID ( link . cid )
90- } catch ( err ) {
91- // fallback to multihash
92- cidOfNextFile = new CID ( mh . toB58String ( link . multihash ) )
93- }
82+ for ( let link of dagNode . Links ) {
83+ if ( link . Name === nextFileName ) {
84+ cidOfNextFile = link . Hash
9485 break
9586 }
9687 }
@@ -129,7 +120,7 @@ const cid = promisify((ipfs, path, callback) => {
129120 }
130121
131122 try {
132- let dagDataObj = Unixfs . unmarshal ( dagResult . value . data )
123+ let dagDataObj = Unixfs . unmarshal ( dagResult . value . Data )
133124 // There are at least two types of directories:
134125 // - "directory"
135126 // - "hamt-sharded-directory" (example: QmT5NvUtoM5nWFfrQdVrFtvGfKFmG7AHE8P34isapyhCxX)
0 commit comments