Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
interface-go-dms3-core
Commits
360e8bbf
Commit
360e8bbf
authored
Jan 04, 2019
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix offline gateway directory logic
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
89157f98
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
path.go
path.go
+7
-2
tests/path.go
tests/path.go
+12
-0
No files found.
path.go
View file @
360e8bbf
package
iface
package
iface
import
(
import
(
"gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
ipfspath
"gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path"
ipfspath
"gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path"
cid
"gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
)
)
//TODO: merge with ipfspath so we don't depend on it
//TODO: merge with ipfspath so we don't depend on it
...
@@ -106,6 +105,12 @@ type resolvedPath struct {
...
@@ -106,6 +105,12 @@ type resolvedPath struct {
remainder
string
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
// IpfsPath creates new /ipfs path from the provided CID
func
IpfsPath
(
c
cid
.
Cid
)
ResolvedPath
{
func
IpfsPath
(
c
cid
.
Cid
)
ResolvedPath
{
return
&
resolvedPath
{
return
&
resolvedPath
{
...
...
tests/path.go
View file @
360e8bbf
...
@@ -15,6 +15,7 @@ func (tp *provider) TestPath(t *testing.T) {
...
@@ -15,6 +15,7 @@ func (tp *provider) TestPath(t *testing.T) {
t
.
Run
(
"TestEmptyPathRemainder"
,
tp
.
TestEmptyPathRemainder
)
t
.
Run
(
"TestEmptyPathRemainder"
,
tp
.
TestEmptyPathRemainder
)
t
.
Run
(
"TestInvalidPathRemainder"
,
tp
.
TestInvalidPathRemainder
)
t
.
Run
(
"TestInvalidPathRemainder"
,
tp
.
TestInvalidPathRemainder
)
t
.
Run
(
"TestPathRoot"
,
tp
.
TestPathRoot
)
t
.
Run
(
"TestPathRoot"
,
tp
.
TestPathRoot
)
t
.
Run
(
"TestPathJoin"
,
tp
.
TestPathJoin
)
}
}
func
(
tp
*
provider
)
TestMutablePath
(
t
*
testing
.
T
)
{
func
(
tp
*
provider
)
TestMutablePath
(
t
*
testing
.
T
)
{
...
@@ -165,3 +166,14 @@ func (tp *provider) TestPathRoot(t *testing.T) {
...
@@ -165,3 +166,14 @@ func (tp *provider) TestPathRoot(t *testing.T) {
t
.
Error
(
"unexpected path cid"
)
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"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment