feat: Relax URL matching (#3925)

* feat: Relax URL matching

Instead of only linkifying things with an explicit http or https scheme,
the xurls.Relaxed also matches links with known TLDs. This means that
text like 'banana.com' will also be matched, despite the missing
http/https scheme. This also works to linkify email addresses, which is
handy.

This should also ensure we catch links without a scheme for the purpose
of spam checking.
This commit is contained in:
Daenney 2025-03-24 14:13:32 +01:00 committed by GitHub
commit 1bf40e755c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 7 additions and 13 deletions

View file

@ -375,7 +375,7 @@ func (f *Filter) errantLinks(
}
// Find + parse every http/https link in the status.
rawLinks := regexes.LinkScheme.FindAllString(concat, -1)
rawLinks := regexes.URLLike.FindAllString(concat, -1)
links := make([]preppedLink, 0, len(rawLinks))
for _, rawLink := range rawLinks {
linkURI, err := url.Parse(rawLink)