mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-09 18:28:08 +08:00
Fix offline gateway directory logic
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@360e8bbf0b This commit was moved from ipfs/boxo@aecc5aa1ac
This commit is contained in:
parent
f012ef096a
commit
80aace0fa2
@ -1,9 +1,8 @@
|
||||
package iface
|
||||
|
||||
import (
|
||||
"gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
|
||||
ipfspath "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path"
|
||||
|
||||
cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
|
||||
)
|
||||
|
||||
//TODO: merge with ipfspath so we don't depend on it
|
||||
@ -106,6 +105,12 @@ type resolvedPath struct {
|
||||
remainder string
|
||||
}
|
||||
|
||||
// Join appends provided segments to the base path
|
||||
func Join(base Path, a ...string) Path {
|
||||
s := ipfspath.Join(append([]string{base.String()}, a...))
|
||||
return &path{path: ipfspath.FromString(s)}
|
||||
}
|
||||
|
||||
// IpfsPath creates new /ipfs path from the provided CID
|
||||
func IpfsPath(c cid.Cid) ResolvedPath {
|
||||
return &resolvedPath{
|
||||
|
||||
@ -15,6 +15,7 @@ func (tp *provider) TestPath(t *testing.T) {
|
||||
t.Run("TestEmptyPathRemainder", tp.TestEmptyPathRemainder)
|
||||
t.Run("TestInvalidPathRemainder", tp.TestInvalidPathRemainder)
|
||||
t.Run("TestPathRoot", tp.TestPathRoot)
|
||||
t.Run("TestPathJoin", tp.TestPathJoin)
|
||||
}
|
||||
|
||||
func (tp *provider) TestMutablePath(t *testing.T) {
|
||||
@ -165,3 +166,14 @@ func (tp *provider) TestPathRoot(t *testing.T) {
|
||||
t.Error("unexpected path cid")
|
||||
}
|
||||
}
|
||||
|
||||
func (tp *provider) TestPathJoin(t *testing.T) {
|
||||
p1, err := coreiface.ParsePath("/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if coreiface.Join(p1, "foo").String() != "/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz/foo" {
|
||||
t.Error("unexpected path")
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user