ranfdev/Geopard

Relative links dont work

trufae opened this issue · 3 comments

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to gemini://lolcathost.org/
  2. Click on recipes
  3. Scroll down and click on BROKEN LINK
  4. See error

Expected behavior

Works fine if i do /recipes/fregides.gmi . this link works well in lagrange

Screenshots
If applicable, add screenshots to help explain your problem.

Software info (please complete the following information):

  • OS: Ubuntu / flatpak
  • Geopard's Version 1.5.0

Additional context
Add any other context about the problem here.

I can reproduce this on the latest commit. Might be related to b27023f

Looks like the culprit here is parse_link from Hypertext. The issue stems from base_url() function of url::ParseOptions that cuts path elements from provided URL, if it doesn't have a trailing slash. This is a intended behavior, as noted in join() function (here).

@ranfdev How we should fix it? Lagrange for example just adds a trailing slash at the end of every URL. We could do that, or add a check in parse_link to know when to add slash.

I've tested the behavior of a simple http server running with python -m http.server, in a folder containing the files

├── subdir
│   ├── index.html
│   └── test.html

Once I try going to localhost/subdir, the python server redirects me to localhost/sudir/, adding a slash.
The slash should be added by the server. Only the server knows if localhost/subdir is a file or a folder.

Even the official gemini documentation does this. You can do, from your terminal

echo "gemini://geminiprotocol.net" | gnutls-cli --tofu -p 1965 geminiprotocol.net

and you'll see a redirect

31 gemini://geminiprotocol.net/

Now, for some reason Geopard doesn't update the URL after the redirect. So the slash doesn't seem to be added. That's a problem we can work on.