Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dnslink-gw): breadcrumbs and CID column when dir listing #7699

Merged
merged 4 commits into from
Nov 10, 2020

Conversation

lidel
Copy link
Member

@lidel lidel commented Sep 25, 2020

This PR aims to solve issue described in ipfs/dir-index-html#42
It changes URI of some broken links when directory listing occurs on DNSLink website adds a bunch of tests.

Changes

There are no visual changes to the way directory listing is presented.

  • fixed breadcrumbs on dnslink website
  • fixed CID column on dnslink website
  • proper test coverage of dir listing (until now we were very lucki, as we had nearly no tests)
    • etag/cache control
    • path edge cases: /api /ipfsandą/ś/ć` (utf8)
    • breadcrumbs (path, subdomain, dnslink)
    • CID column (path, subdomain, dnslink)
  • make everything work with X-Ipfs-Gateway-Prefix

How to tests this PR

This PR mainly fixes the DNSLink mode, which is when domain passed in Host header has a valid DNSLink record:

$ curl -H "Host: dist.ipfs.io" -sD - "http://127.0.0.1:8080/go-ipfs/v0.7.0"

It may be tricky to understand what is the fix. The best illustration is to look at CID column:

  • when path or subdomain gateway is used, CID column links to direct CID with filename parameter:
    $ curl -sD - "http://127.0.0.1:8080/ipns/dist.ipfs.io/go-ipfs/v0.7.0" | grep "ipfs-hash"
    <a class="ipfs-hash" href="/ipfs/Qmf9JEWyETbLmAdyT9BaBStNeJ2ZHgvgXFNSWgdz9saa4N?filename=go-ipfs_v0.7.0_darwin-386.tar.gz">
  • when DNSLink gateway is used (Host header), CID column links to cid.ipfs.io:
    $ curl -H "Host: dist.ipfs.io" -sD - "http://127.0.0.1:8280/go-ipfs/v0.7.0" | grep "ipfs-hash"
    <a class="ipfs-hash" href="https://cid.ipfs.io/#Qmf9JEWyETbLmAdyT9BaBStNeJ2ZHgvgXFNSWgdz9saa4N" target="_blank" rel="noreferrer noopener">

Similar fix is applied to breadcrumbs, but we link to domain from dnslink instead of a public gateway.

This switches go-ipfs to dir-index-html after
ipfs/dir-index-html#43
got merged to master
@jessicaschilling
Copy link
Contributor

@lidel Apologies for the delay - v1.2.1 of dir-index-html is here: https://github.com/ipfs/dir-index-html/releases/tag/1.2.1

This adds proper end-to-end tests for directory listing on Gateway port
that protects us against regressions oni each gw type:
- path gateway
- subdomain gateway
- dnslink website gateway

Tests cover:
- etag/unicode support
- breadcrumbs
- file name column
- hash column
#
# Copyright (c) Protocol Labs

test_description="Test directory listing (dir-index-html) on the HTTP gateway"
Copy link
Member Author

@lidel lidel Sep 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭

This file adds proper end-to-end tests for directory listing on Gateway port that protects us against regressions such as ipfs/dir-index-html#42 by testing each gateway type:

  • path gateway
  • subdomain gateway
  • dnslink website gateway

We check behavior of:

  • etag/unicode support
  • breadcrumbs
  • file name column
  • hash column

This level of testing is necessary, because URIs will be different on each gw type, and we literally had no tests for this apart from subdomain ones. Now we test all gw types and I can sleep better ;)

@lidel lidel marked this pull request as ready for review September 29, 2020 01:06
@lidel
Copy link
Member Author

lidel commented Sep 29, 2020

@aschmahmann I believe this is ready for your review.

@lidel lidel added the need/review Needs a review label Sep 29, 2020
@aschmahmann aschmahmann merged commit 499e011 into master Nov 10, 2020
@lidel lidel deleted the fix/dnslink-dir-listing branch November 13, 2020 14:06
@aschmahmann aschmahmann mentioned this pull request Feb 18, 2021
73 tasks
hacdias pushed a commit to ipfs/boxo that referenced this pull request Jan 27, 2023
fix(dnslink-gw): breadcrumbs and CID column when dir listing

This commit was moved from ipfs/kubo@499e011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/review Needs a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants