Skip to content

Commit

Permalink
refactor: remove NewDNSLinkPath and NewIPNSPath
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Aug 14, 2023
1 parent 5d8605d commit 2744ea9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
12 changes: 9 additions & 3 deletions gateway/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ func TestGatewayGet(t *testing.T) {
k, err := backend.resolvePathNoRootsReturned(ctx, p)
require.NoError(t, err)

mustMakeDNSLinkPath := func(domain string) path.Path {
p, err := path.NewPath("/ipns/" + domain)
require.NoError(t, err)
return p
}

backend.namesys["/ipns/example.com"] = path.NewIPFSPath(k.Cid())
backend.namesys["/ipns/working.example.com"] = k
backend.namesys["/ipns/double.example.com"] = path.NewDNSLinkPath("working.example.com")
backend.namesys["/ipns/triple.example.com"] = path.NewDNSLinkPath("double.example.com")
backend.namesys["/ipns/broken.example.com"] = path.NewDNSLinkPath(k.Cid().String())
backend.namesys["/ipns/double.example.com"] = mustMakeDNSLinkPath("working.example.com")
backend.namesys["/ipns/triple.example.com"] = mustMakeDNSLinkPath("double.example.com")
backend.namesys["/ipns/broken.example.com"] = mustMakeDNSLinkPath(k.Cid().String())
// We picked .man because:
// 1. It's a valid TLD.
// 2. Go treats it as the file extension for "man" files (even though
Expand Down
18 changes: 0 additions & 18 deletions path/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,24 +182,6 @@ func NewIPLDPath(cid cid.Cid) ResolvedPath {
}

Check warning on line 182 in path/path.go

View check run for this annotation

Codecov / codecov/patch

path/path.go#L173-L182

Added lines #L173 - L182 were not covered by tests
}

// NewIPNSPath returns a new "/ipns" path with the provided CID.
func NewIPNSPath(cid cid.Cid) Path {
return &path{
str: fmt.Sprintf("/%s/%s", IPNSNamespace, cid.String()),
root: cid,
namespace: IPNSNamespace,
}
}

// NewDNSLinkPath returns a new "/ipns" path with the provided domain.
func NewDNSLinkPath(domain string) Path {
return &path{
str: fmt.Sprintf("/%s/%s", IPNSNamespace, domain),
root: cid.Undef,
namespace: IPNSNamespace,
}
}

// NewPath takes the given string and returns a well-forme and sanitized [Path].
// The given string is cleaned through [gopath.Clean], but preserving the final
// trailing slash. This function returns an error when the given string is not
Expand Down

0 comments on commit 2744ea9

Please sign in to comment.