@cryptotaxi247 / kubo / commits / 80aace0fa

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@360e8bbf0b798f4c52541d9116e3b2d240c71a9a This commit was moved from ipfs/boxo@aecc5aa1ac7d14502faf74530e73fb801aed4158

Łukasz Magiera committed Jan 4, 2019 at 02:35 UTC 80aace0fa25dcc9d89aff8f3b767852c2935685f
2 files changed +19 -2
core/coreiface/path.go
+7 -2
@@ -1,9 +1,8 @@
1 package iface
2
3 import (
4 + "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
5 ipfspath "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path"
5 -
6 - cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
6 )
7
8 //TODO: merge with ipfspath so we don't depend on it
@@ -106,6 +105,12 @@ type resolvedPath struct {
105 remainder string
106 }
107
108 +// Join appends provided segments to the base path
109 +func Join(base Path, a ...string) Path {
110 + s := ipfspath.Join(append([]string{base.String()}, a...))
111 + return &path{path: ipfspath.FromString(s)}
112 +}
113 +
114 // IpfsPath creates new /ipfs path from the provided CID
115 func IpfsPath(c cid.Cid) ResolvedPath {
116 return &resolvedPath{
core/coreiface/tests/path.go
+12
@@ -15,6 +15,7 @@ func (tp *provider) TestPath(t *testing.T) {
15 t.Run("TestEmptyPathRemainder", tp.TestEmptyPathRemainder)
16 t.Run("TestInvalidPathRemainder", tp.TestInvalidPathRemainder)
17 t.Run("TestPathRoot", tp.TestPathRoot)
18 + t.Run("TestPathJoin", tp.TestPathJoin)
19 }
20
21 func (tp *provider) TestMutablePath(t *testing.T) {
@@ -165,3 +166,14 @@ func (tp *provider) TestPathRoot(t *testing.T) {
166 t.Error("unexpected path cid")
167 }
168 }
169 +
170 +func (tp *provider) TestPathJoin(t *testing.T) {
171 + p1, err := coreiface.ParsePath("/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz")
172 + if err != nil {
173 + t.Error(err)
174 + }
175 +
176 + if coreiface.Join(p1, "foo").String() != "/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz/foo" {
177 + t.Error("unexpected path")
178 + }
179 +}