Skip to content

Commit ce70743

Browse files
committedJul 14, 2015
fix parsing for paths of format <hash>/path
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
1 parent 498e927 commit ce70743

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
 

‎path/path.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ func ParsePath(txt string) (Path, error) {
5656
return kp, nil
5757
}
5858
}
59-
if len(parts) < 3 {
60-
return "", ErrBadPath
61-
}
6259

60+
// if the path doesnt being with a '/'
61+
// we expect this to start with a hash, and be an 'ipfs' path
6362
if parts[0] != "" {
6463
if _, err := ParseKeyToPath(parts[0]); err != nil {
6564
return "", ErrBadPath
@@ -68,6 +67,10 @@ func ParsePath(txt string) (Path, error) {
6867
return Path("/ipfs/" + txt), nil
6968
}
7069

70+
if len(parts) < 3 {
71+
return "", ErrBadPath
72+
}
73+
7174
if parts[1] == "ipfs" {
7275
if _, err := ParseKeyToPath(parts[2]); err != nil {
7376
return "", err

0 commit comments

Comments
 (0)
Please sign in to comment.