Skip to content

Modify linkRegex to require http|https#6153

Closed
mrsdizzie wants to merge 0 commit into
go-gitea:masterfrom
mrsdizzie:master
Closed

Modify linkRegex to require http|https#6153
mrsdizzie wants to merge 0 commit into
go-gitea:masterfrom
mrsdizzie:master

Conversation

@mrsdizzie

Copy link
Copy Markdown
Member

Existing code comments suggest this should only match http/https links but it
matches anything starting with www as well (and creates broken links as
a result). Change behavior of regex to match what appears to be the
Intended behavior. This is related to #6146

@codecov-io

codecov-io commented Feb 21, 2019

Copy link
Copy Markdown

Codecov Report

Merging #6153 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6153      +/-   ##
==========================================
+ Coverage   38.83%   38.84%   +<.01%     
==========================================
  Files         354      354              
  Lines       50183    50183              
==========================================
+ Hits        19490    19494       +4     
+ Misses      27868    27863       -5     
- Partials     2825     2826       +1
Impacted Files Coverage Δ
modules/markup/html.go 89.59% <ø> (ø) ⬆️
models/repo_list.go 66.84% <0%> (-1.06%) ⬇️
routers/repo/view.go 42.07% <0%> (+0.99%) ⬆️
models/unit.go 14.28% <0%> (+14.28%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0514376...6e9b776. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 21, 2019
@techknowlogick

Copy link
Copy Markdown
Member

Can you add some tests?

@zeripath

Copy link
Copy Markdown
Contributor

I think that we should really handle the www.example.com cases. It shouldn't be too hard to just add http:// as necessary.

@mrsdizzie

Copy link
Copy Markdown
Member Author

I deal with a lot of hostnames, so linking anything that starts with www (but then not any other hostname) doesn't feel ideal and also feels inconsistent. Having a list of hostnames like

www.example.com
test.example.com
blog.example.com
www.blog.example.com
ftp.example.com
example.com
try.gitea.io

Where some get automatically turned into a link and the others don't can seem a bit odd. I understand this probably isn't the most common use case, but requiring http|https also gives people a good and obvious option for being specific when they want to generate a link or not, which I think is nice bonus.

I see both sides for sure and can also see that github also has similar behavior people might be used to, but requiring http|https would create a much more intentional situation where gitea would never do the undesirable thing when creating a link.

Thanks for the feedback!

@zeripath

Copy link
Copy Markdown
Contributor

Hmm. I guess leaving this in a broken state is worse than useless so I'll approve this and we can think about adding back in the other support if people want.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 23, 2019
@mrsdizzie

Copy link
Copy Markdown
Member Author

OK cool! Agree this definitely needs some comprehensive tests so I'll look into that aspect now

@mrsdizzie mrsdizzie closed this Feb 23, 2019
@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

lgtm/need 1 This PR needs approval from one additional maintainer to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants