Skip to content

Commit

Permalink
Merge pull request #464 from ipfs/gw-trailing-s-dirs
Browse files Browse the repository at this point in the history
gateway: explain why we normalize to trailing slash in dir URLs
  • Loading branch information
lidel authored Feb 29, 2024
2 parents 971db4c + 5573743 commit 937754a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/http-gateways/path-gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,16 @@ This header is more widely used in [SUBDOMAIN_GATEWAY.md](./SUBDOMAIN_GATEWAY.md
Gateway MUST return a redirect when a valid UnixFS directory was requested
without the trailing `/`, for example:

- response for `https://ipfs.io/ipns/en.wikipedia-on-ipfs.org/wiki`
(no trailing slash) will be HTTP 301 redirect with
- response for UnixFS directory at `https://example.com/ipns/en.wikipedia-on-ipfs.org/wiki`
(no trailing slash) MUST be HTTP 301 redirect with
`Location: /ipns/en.wikipedia-on-ipfs.org/wiki/`

This normalization is required for directory-based relative links
and security scopes such as Service Worker registrations to work correctly.
It also ensures the same behavior on path gateways (`https://example.com/ipfs/cid/` with trailing `/`)
and origin-isolated HTTP contexts `https://cid.ipfs.dweb.link`
or non-HTTP URLs like `ipfs://cid`, where empty path component is implicit `/`.

### `X-Ipfs-Path` (response header)

Used for HTTP caching and indicating the IPFS address of the data.
Expand Down

0 comments on commit 937754a

Please sign in to comment.