Skip to content

Commit

Permalink
Merge pull request ipfs/kubo#6122 from ipfs/feat/coreapi/path-errs
Browse files Browse the repository at this point in the history
coreapi: Drop error from ParsePath

This commit was moved from ipfs/kubo@c8e34bc
  • Loading branch information
Stebalien authored Apr 17, 2019
2 parents d724a2c + 6832490 commit 7b38742
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions gateway/core/corehttp/gateway_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
ft "github.com/ipfs/go-unixfs"
"github.com/ipfs/go-unixfs/importer"
coreiface "github.com/ipfs/interface-go-ipfs-core"
ipath "github.com/ipfs/interface-go-ipfs-core/path"
"github.com/libp2p/go-libp2p-routing"
"github.com/multiformats/go-multibase"
)
Expand Down Expand Up @@ -147,8 +148,8 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
ipnsHostname = true
}

parsedPath, err := coreiface.ParsePath(urlPath)
if err != nil {
parsedPath := ipath.New(urlPath)
if err := parsedPath.IsValid(); err != nil {
webError(w, "invalid ipfs path", err, http.StatusBadRequest)
return
}
Expand Down Expand Up @@ -246,7 +247,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
return
}

idx, err := i.api.Unixfs().Get(ctx, coreiface.Join(resolvedPath, "index.html"))
idx, err := i.api.Unixfs().Get(ctx, ipath.Join(resolvedPath, "index.html"))
switch err.(type) {
case nil:
dirwithoutslash := urlPath[len(urlPath)-1] != '/'
Expand Down
5 changes: 3 additions & 2 deletions gateway/core/corehttp/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
path "github.com/ipfs/go-path"
iface "github.com/ipfs/interface-go-ipfs-core"
nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys"
ipath "github.com/ipfs/interface-go-ipfs-core/path"
ci "github.com/libp2p/go-libp2p-crypto"
id "github.com/libp2p/go-libp2p/p2p/protocol/identify"
)
Expand Down Expand Up @@ -344,12 +345,12 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
t.Fatal(err)
}

k2, err := api.ResolvePath(ctx, iface.Join(k, "foo? #<'"))
k2, err := api.ResolvePath(ctx, ipath.Join(k, "foo? #<'"))
if err != nil {
t.Fatal(err)
}

k3, err := api.ResolvePath(ctx, iface.Join(k, "foo? #<'/bar"))
k3, err := api.ResolvePath(ctx, ipath.Join(k, "foo? #<'/bar"))
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 7b38742

Please sign in to comment.