Skip to content

Commit

Permalink
gw: explain why we normalize trailing slash in dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Feb 29, 2024
1 parent 971db4c commit 7684240
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 7684240

Please sign in to comment.