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(gw): directory URL normalization #9123

Merged
merged 2 commits into from
Jul 21, 2022
Merged

Conversation

lidel
Copy link
Member

@lidel lidel commented Jul 18, 2022

tl;dr

This PR fixes a regression around directory listing and index.html hosting,
and makes Kubo behavior compliant with desired Gateway Specs here.

Why

Seems that during one of recent refactors code changed and we no longer check for trailing slash in HTTP request path. Most likely, this happened when we switched from raw URL path to content path.

This regression meant Kubo was not following specs at
/ipfs/specs/http-gateways/PATH_GATEWAY.md#use-in-directory-url-normalization.

What

This PR:

  • cleans things up so we always redirect directories from /ipfs/cid/foo to /ipfs/cid/foo/
  • adds more tests, so we catch any future regressions.

@lidel lidel requested a review from Jorropo July 18, 2022 23:41
@lidel lidel force-pushed the fix/gw-trailing-slash-unixfs-dirs branch 2 times, most recently from e1662ca to 35db1a4 Compare July 18, 2022 23:57
@lidel lidel force-pushed the fix/gw-trailing-slash-unixfs-dirs branch from 35db1a4 to 0d57edb Compare July 19, 2022 00:09
@lidel lidel marked this pull request as ready for review July 19, 2022 00:28
@lidel lidel requested a review from iand July 20, 2022 14:23
Copy link
Contributor

@iand iand left a comment

Choose a reason for hiding this comment

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

LGTM, some minor typos in tests

test/sharness/t0115-gateway-dir-listing.sh Outdated Show resolved Hide resolved
test/sharness/t0115-gateway-dir-listing.sh Outdated Show resolved Hide resolved
test/sharness/t0115-gateway-dir-listing.sh Outdated Show resolved Hide resolved
@lidel lidel force-pushed the fix/gw-trailing-slash-unixfs-dirs branch from 68d8236 to 7d7faed Compare July 21, 2022 19:03
This adds a missing test for #3963
This fixes a regression around directory listing and index.html hosting.
Seems that during one of recent refactors code changed and we no longer
check for trailing slash in HTTP request path, but look at content path
instead.

This cleans this up and also ensures dir behavior is the same for
both index.html hosting and dir-index-html (generated listing).

It also adds more tests so we catch any future regressions.
@lidel lidel force-pushed the fix/gw-trailing-slash-unixfs-dirs branch from 7d7faed to 3182986 Compare July 21, 2022 19:06
@lidel lidel merged commit cf82ae5 into master Jul 21, 2022
@lidel lidel deleted the fix/gw-trailing-slash-unixfs-dirs branch July 21, 2022 19:34
@ajnavarro ajnavarro mentioned this pull request Aug 24, 2022
72 tasks
hacdias pushed a commit to ipfs/boxo that referenced this pull request Jan 27, 2023
…xfs-dirs

fix(gw): directory URL normalization

This commit was moved from ipfs/kubo@cf82ae5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants