Skip to content

Commit 195ff42

Browse files
authored
fix: return nested value from dag.get (#3966)
If we're traversing thorough and object and the thing at the end of the path is a CID, load that thing and return it as the final value, unless `localResolve` is true, in which case return the CID. Fixes #3957
1 parent c96fd7b commit 195ff42

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/lib/resolve.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ export async function * resolve (cid, path, codecs, getBlock, options) {
2929
let value = await load(cid)
3030
let lastCid = cid
3131

32-
if (!parts.length) {
33-
yield {
34-
value,
35-
remainderPath: ''
36-
}
37-
}
38-
3932
// End iteration if there isn't a CID to follow any more
4033
while (parts.length) {
4134
const key = parts.shift()
@@ -62,4 +55,9 @@ export async function * resolve (cid, path, codecs, getBlock, options) {
6255
value = await load(value)
6356
}
6457
}
58+
59+
yield {
60+
value,
61+
remainderPath: ''
62+
}
6563
}

0 commit comments

Comments
 (0)