ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.14k stars 3.02k forks source link

dir-index-html: directory listings contain wrong links #8813

Open RubenKelevra opened 3 years ago

RubenKelevra commented 3 years ago

Describe the bug I use the in brave integrated ipfs functionality which includes the ipfs companion.

When clicking on an ipns enabled link, like http://x86-64.archlinux.pkg.pacman.store/iso it will redirect me to ipns://x86-64.archlinux.pkg.pacman.store/iso which looks exactly how it should.

But the listing of directories on this page contain wrong links in this case, like http://x86-64.archlinux.pkg.pacman.store.ipns.localhost:48084/iso/2021.07.01. They will work, but completely change the layout of the URL.

I'm not sure where the listing is created, and if the companion or the brave browser just fails to instruct the part of the ipfs eco system to use other links?

To Reproduce Steps to reproduce the behavior:

  1. Go to http://x86-64.archlinux.pkg.pacman.store/iso
  2. Hover over any link.
  3. See links containing http:// localhost and the port.

Expected behavior Keep the users in the ipns:// URL space.

Desktop (please complete the following information):

lidel commented 3 years ago

A realistic long-term fix here is to add JS snippet to dir listing HTML that:

  1. detects when window.location.origin starts with ipfs:// (requires https://github.com/brave/brave-browser/issues/13303)
  2. replaces all http://*.ip[n|f]s.localhost:{port} with ipfs:// versions