1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-29 01:12:24 +08:00

fix: return the shortest, completely resolved path in the resolve command

fixes #5703

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
Steven Allen
2018-10-30 10:22:34 -07:00
parent ef94a43e8a
commit 4bb1cb65e8
2 changed files with 11 additions and 10 deletions

View File

@ -140,13 +140,12 @@ Resolve the value of an IPFS DAG path:
return err
}
if rp.Remainder() != "" {
// TODO: js expects this error. Instead of fixing this
// error, we should fix #5703.
return fmt.Errorf("found non-link at given path")
encoded := "/" + rp.Namespace() + "/" + enc.Encode(rp.Cid())
if remainder := rp.Remainder(); remainder != "" {
encoded += "/" + remainder
}
return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: path.Path("/" + rp.Namespace() + "/" + enc.Encode(rp.Cid()))})
return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: path.Path(encoded)})
},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, rp *ncmd.ResolvedPath) error {