1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-10-25 02:16:56 +08:00

fix parsing for paths of format <hash>/path

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
Jeromy
2015-07-14 12:01:01 -07:00
parent 498e927ac7
commit ce70743829

View File

@ -56,10 +56,9 @@ func ParsePath(txt string) (Path, error) {
return kp, nil
}
}
if len(parts) < 3 {
return "", ErrBadPath
}
// if the path doesnt being with a '/'
// we expect this to start with a hash, and be an 'ipfs' path
if parts[0] != "" {
if _, err := ParseKeyToPath(parts[0]); err != nil {
return "", ErrBadPath
@ -68,6 +67,10 @@ func ParsePath(txt string) (Path, error) {
return Path("/ipfs/" + txt), nil
}
if len(parts) < 3 {
return "", ErrBadPath
}
if parts[1] == "ipfs" {
if _, err := ParseKeyToPath(parts[2]); err != nil {
return "", err