Skip to content

Commit

Permalink
fix: return nested value from dag.get (#3966)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
achingbrain authored Dec 6, 2021
1 parent c96fd7b commit 195ff42
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/lib/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ export async function * resolve (cid, path, codecs, getBlock, options) {
let value = await load(cid)
let lastCid = cid

if (!parts.length) {
yield {
value,
remainderPath: ''
}
}

// End iteration if there isn't a CID to follow any more
while (parts.length) {
const key = parts.shift()
Expand All @@ -62,4 +55,9 @@ export async function * resolve (cid, path, codecs, getBlock, options) {
value = await load(value)
}
}

yield {
value,
remainderPath: ''
}
}

0 comments on commit 195ff42

Please sign in to comment.