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

[gnoweb]: Markdown links not rendering the expected path #3865

Open
ajnavarro opened this issue Mar 1, 2025 · 2 comments · May be fixed by #3981
Open

[gnoweb]: Markdown links not rendering the expected path #3865

ajnavarro opened this issue Mar 1, 2025 · 2 comments · May be fixed by #3981
Assignees
Labels
🐞 bug Something isn't working

Comments

@ajnavarro
Copy link
Contributor

ajnavarro commented Mar 1, 2025

Markdown links not rendering the expected path

Description

Gnoweb does not render markdown links correctly, if we have the following markdown code render at http://127.0.0.1:8888/r/gov/dao/proxy:

- [Go to votes list](:2/votes).

The expected link must point to: http://127.0.0.1:8888/r/gov/dao/proxy:2/votes but it is actually pointing to http://127.0.0.1:8888/r/gov/dao:2/votes

Your environment

  • go1.21.0)
  • linux/amd64
  • b551f40 (master)

Steps to reproduce

  • Generate a simple realm with the provided markdown code returned when calling Render method. Click to the link.

Expected behaviour

Already explained on the description.

Actual behaviour

Already explained on the description

Proposed solution

Render the link as it should be. If it is not possible because we are using two dots that are not defined on the HTML hyperlink standards, ✨ use the standards ✨.

@alexiscolin
Copy link
Member

@ajnavarro This is not a gnoweb or Markdown bug, it's simply how browsers resolve relative URLs starting with a colon (or any kind of char). If you write :2/votes from foo/bar/proxy, proxy is dropped according to the standard URL rules. There’s no alternative way to append everything after the last path word once a colon is the first character in the new segment.

Some (Standard) solutions:

  • Absolute URL (obviously not an option)
    [Go to votes list](http://127.0.0.1:8888/r/gov/dao/proxy:2/votes)

  • Explicit relative link
    [Go to votes list](./proxy:2/votes)

Note:
Other paths starting with any character (like ./, ../, etc.) follow the same standard rules. If the current URL does not end with a trailing slash (/), these paths replace the last segment instead of appending to it. So, there’s no built-in mechanism to simply tack :2/votes onto proxy without explicitly including proxy in the path. Unfortunatly, the trailing slash is reserved in gnoweb to render the current realm directory.

@ajnavarro
Copy link
Contributor Author

Colons are not defined in the HTTP hyperlink standards as special separator and it can be used as a valid character in path segments. That might cause problems. Fragments (#) and query (?) params work as I explained above with relative links.

Because of that, I think we have to move from using colons to use fragments to handle URLs in a better way. If we don't do that, we are doomed to always copy and paste the complete realm path.

If you are at http://127.0.0.1:8888/r/gov/dao/proxy and you click :2/votes , right now because colons are valid character on path, the final URL will be http://127.0.0.1:8888/r/gov/dao/:2/votes making no sense in any case.

If you are at http://127.0.0.1:8888/r/gov/dao/proxy and you click #2/votes , then the fragment is detected and you are properly redirected to http://127.0.0.1:8888/r/gov/dao/proxy#2/votes making much more sense IMO.

@alexiscolin alexiscolin linked a pull request Mar 20, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
Status: Triage
Development

Successfully merging a pull request may close this issue.

2 participants