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:
@ -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 {
|
||||
|
Reference in New Issue
Block a user