Skip to content

Autolinked URLs: fragment components not included in generated link #5844

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

Closed
veita opened this issue Jan 25, 2019 · 7 comments
Closed

Autolinked URLs: fragment components not included in generated link #5844

veita opened this issue Jan 25, 2019 · 7 comments
Labels

Comments

@veita
Copy link

veita commented Jan 25, 2019

Description

Some autolinked URLs are not linked correctly. E.g.

https://github.com/go-gitea/gitea/?p=aaa/bbb.html#ccc-ddd

is rendered without the fragment component. The same URL works on GitHub:

https://github.com/go-gitea/gitea/?p=aaa/bbb.html#ccc-ddd

@lunny lunny added the type/bug label Feb 7, 2019
@lunny
Copy link
Member

lunny commented Feb 7, 2019

Which gitea version are you using?

@veita
Copy link
Author

veita commented Feb 8, 2019

Gitea version 1.6.3 or 1.6.4.

@veita
Copy link
Author

veita commented Feb 8, 2019

The issue exist also in version 1.7.1.

@zeripath
Copy link
Contributor

zeripath commented Feb 8, 2019

@veita could you give an example of a Gitea path that doesn't work on try.gitea.io . It would hello to completely identify and fix this issue

@veita
Copy link
Author

veita commented Feb 9, 2019

Just put the link given in the issue description into a README.md or wiki page. Then you'll see that #ccc-ddd is not rendered as a part of the generated link.

mrsdizzie added a commit to mrsdizzie/gitea that referenced this issue Mar 7, 2019
Rather than maintaining a complicated regex to match URLs for
autolinking, gitea can use this existing go library that takes care of
the matching with very little code change to gitea itself. After
spending a while trying to find the perfect regex for all cases this library
still works better as it is more flexible than a single regex ever will be.

This will also fix the following issues: go-gitea#5844 go-gitea#3095 go-gitea#3381

This passes all our current tests and I've added new ones mentioned in
those issues as well.
techknowlogick pushed a commit that referenced this issue Mar 7, 2019
* Replace linkRegex with xurls library

Rather than maintaining a complicated regex to match URLs for
autolinking, gitea can use this existing go library that takes care of
the matching with very little code change to gitea itself. After
spending a while trying to find the perfect regex for all cases this library
still works better as it is more flexible than a single regex ever will be.

This will also fix the following issues: #5844 #3095 #3381

This passes all our current tests and I've added new ones mentioned in
those issues as well.

* Use xurls.StrictMatchingScheme instead of xurls.Strict

This is much faster and we only care about https? links to preserve
existing behavior.
@techknowlogick
Copy link
Member

Closing per merged PR

@veita
Copy link
Author

veita commented Apr 28, 2019

I can confirm that the issue is fixed in Gitea 1.8.0.

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants