@@ -6,8 +6,7 @@ const reduce = require('async/reduce')
6
6
const CID = require ( 'cids' )
7
7
const Unixfs = require ( 'ipfs-unixfs' )
8
8
const 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' )
11
10
12
11
const dirView = require ( './dir-view' )
13
12
const pathUtil = require ( './utils/path' )
@@ -19,13 +18,13 @@ function getIndexFiles (links) {
19
18
'index.shtml'
20
19
]
21
20
// 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 )
23
22
if ( indexes . length ) {
24
23
return indexes
25
24
}
26
25
// hamt-sharded-directory uses a 2 char prefix
27
26
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
29
28
} )
30
29
}
31
30
@@ -38,13 +37,13 @@ const directory = promisify((ipfs, path, cid, callback) => {
38
37
}
39
38
40
39
// Test if it is a Website
41
- const indexFiles = getIndexFiles ( dagNode . links )
40
+ const indexFiles = getIndexFiles ( dagNode . Links )
42
41
43
42
if ( indexFiles . length ) {
44
43
return callback ( null , indexFiles )
45
44
}
46
45
47
- return callback ( null , dirView . render ( path , dagNode . links ) )
46
+ return callback ( null , dirView . render ( path , dagNode . Links ) )
48
47
} )
49
48
} )
50
49
@@ -80,17 +79,9 @@ const cid = promisify((ipfs, path, callback) => {
80
79
const nextFileName = item
81
80
82
81
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
94
85
break
95
86
}
96
87
}
@@ -129,7 +120,7 @@ const cid = promisify((ipfs, path, callback) => {
129
120
}
130
121
131
122
try {
132
- let dagDataObj = Unixfs . unmarshal ( dagResult . value . data )
123
+ let dagDataObj = Unixfs . unmarshal ( dagResult . value . Data )
133
124
// There are at least two types of directories:
134
125
// - "directory"
135
126
// - "hamt-sharded-directory" (example: QmT5NvUtoM5nWFfrQdVrFtvGfKFmG7AHE8P34isapyhCxX)
0 commit comments