Skip to content

Commit

Permalink
Merge pull request ipfs/kubo#7219 from ipfs/fix/listing-header
Browse files Browse the repository at this point in the history
feat(gateway): show the absolute path and CID every time

This commit was moved from ipfs/kubo@ffe35df
  • Loading branch information
Stebalien authored Apr 29, 2020
2 parents b2899d7 + 6161b22 commit c30b301
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 2 additions & 5 deletions gateway/core/corehttp/gateway_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
6 changes: 3 additions & 3 deletions gateway/core/corehttp/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<a href=\"/foo%3F%20%23%3C%27/./..\">") {
Expand Down Expand Up @@ -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? #&lt;&#39;/bar/") {
if !strings.Contains(s, "Index of /ipns/example.net/foo? #&lt;&#39;/bar/") {
t.Fatalf("expected a path in directory listing")
}
if !strings.Contains(s, "<a href=\"/foo%3F%20%23%3C%27/bar/./..\">") {
Expand Down Expand Up @@ -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, "<a href=\"/good-prefix/\">") {
Expand Down

0 comments on commit c30b301

Please sign in to comment.