diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index f91d42b61..2729f04e6 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -330,15 +330,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } } - var hash string - if !strings.HasPrefix(urlPath, ipfsPathPrefix) { - hash = resolvedPath.Cid().String() - } + hash := resolvedPath.Cid().String() // See comment above where originalUrlPath is declared. tplData := listingTemplateData{ Listing: dirListing, - Path: originalUrlPath, + Path: urlPath, BackLink: backLink, Hash: hash, } diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index daf1af07c..edae35e3f 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -378,7 +378,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s := string(body) t.Logf("body: %s\n", string(body)) - if !strings.Contains(s, "Index of /foo? #<'/") { + if !strings.Contains(s, "Index of /ipns/example.net/foo? #<'/") { t.Fatalf("expected a path in directory listing") } if !strings.Contains(s, "") { @@ -444,7 +444,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s = string(body) t.Logf("body: %s\n", string(body)) - if !strings.Contains(s, "Index of /foo? #<'/bar/") { + if !strings.Contains(s, "Index of /ipns/example.net/foo? #<'/bar/") { t.Fatalf("expected a path in directory listing") } if !strings.Contains(s, "") { @@ -478,7 +478,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s = string(body) t.Logf("body: %s\n", string(body)) - if !strings.Contains(s, "Index of /good-prefix") { + if !strings.Contains(s, "Index of /ipns/example.net") { t.Fatalf("expected a path in directory listing") } if !strings.Contains(s, "") {