Skip to content

Commit ffe35df

Browse files
authored
Merge pull request #7219 from ipfs/fix/listing-header
feat(gateway): show the absolute path and CID every time
2 parents 4847083 + 46ae021 commit ffe35df

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

core/corehttp/gateway_handler.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
330330
}
331331
}
332332

333-
var hash string
334-
if !strings.HasPrefix(urlPath, ipfsPathPrefix) {
335-
hash = resolvedPath.Cid().String()
336-
}
333+
hash := resolvedPath.Cid().String()
337334

338335
// See comment above where originalUrlPath is declared.
339336
tplData := listingTemplateData{
340337
Listing: dirListing,
341-
Path: originalUrlPath,
338+
Path: urlPath,
342339
BackLink: backLink,
343340
Hash: hash,
344341
}

core/corehttp/gateway_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
378378
s := string(body)
379379
t.Logf("body: %s\n", string(body))
380380

381-
if !strings.Contains(s, "Index of /foo? #<'/") {
381+
if !strings.Contains(s, "Index of /ipns/example.net/foo? #<'/") {
382382
t.Fatalf("expected a path in directory listing")
383383
}
384384
if !strings.Contains(s, "<a href=\"/foo%3F%20%23%3C%27/./..\">") {
@@ -444,7 +444,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
444444
s = string(body)
445445
t.Logf("body: %s\n", string(body))
446446

447-
if !strings.Contains(s, "Index of /foo? #&lt;&#39;/bar/") {
447+
if !strings.Contains(s, "Index of /ipns/example.net/foo? #&lt;&#39;/bar/") {
448448
t.Fatalf("expected a path in directory listing")
449449
}
450450
if !strings.Contains(s, "<a href=\"/foo%3F%20%23%3C%27/bar/./..\">") {
@@ -478,7 +478,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
478478
s = string(body)
479479
t.Logf("body: %s\n", string(body))
480480

481-
if !strings.Contains(s, "Index of /good-prefix") {
481+
if !strings.Contains(s, "Index of /ipns/example.net") {
482482
t.Fatalf("expected a path in directory listing")
483483
}
484484
if !strings.Contains(s, "<a href=\"/good-prefix/\">") {

0 commit comments

Comments
 (0)