From 2744ea9b468edc211056f88277e360b2ebe5ffe7 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Mon, 14 Aug 2023 15:24:38 +0200 Subject: [PATCH] refactor: remove NewDNSLinkPath and NewIPNSPath --- gateway/gateway_test.go | 12 +++++++++--- path/path.go | 18 ------------------ 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/gateway/gateway_test.go b/gateway/gateway_test.go index af994fe55..26a244f7c 100644 --- a/gateway/gateway_test.go +++ b/gateway/gateway_test.go @@ -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 diff --git a/path/path.go b/path/path.go index 1b6fce123..1738ba0e1 100644 --- a/path/path.go +++ b/path/path.go @@ -182,24 +182,6 @@ func NewIPLDPath(cid cid.Cid) ResolvedPath { } } -// 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