From 77a33f6fb0ddf71f0a08cecb03d291827eed196a Mon Sep 17 00:00:00 2001 From: Daenney Date: Mon, 24 Mar 2025 13:43:15 +0100 Subject: [PATCH] [chore] Review comments --- internal/filter/spam/statusable.go | 2 +- internal/regexes/regexes.go | 8 ++++---- internal/text/markdown.go | 2 +- internal/text/plain.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/filter/spam/statusable.go b/internal/filter/spam/statusable.go index 819d03265..3e9e51697 100644 --- a/internal/filter/spam/statusable.go +++ b/internal/filter/spam/statusable.go @@ -375,7 +375,7 @@ func (f *Filter) errantLinks( } // Find + parse every http/https link in the status. - rawLinks := regexes.URL.FindAllString(concat, -1) + rawLinks := regexes.URLLike.FindAllString(concat, -1) links := make([]preppedLink, 0, len(rawLinks)) for _, rawLink := range rawLinks { linkURI, err := url.Parse(rawLink) diff --git a/internal/regexes/regexes.go b/internal/regexes/regexes.go index a8a190645..a94387e47 100644 --- a/internal/regexes/regexes.go +++ b/internal/regexes/regexes.go @@ -22,7 +22,7 @@ import ( "regexp" "sync" - "mvdan.cc/xurls/v2" + xurls "mvdan.cc/xurls/v2" ) const ( @@ -78,9 +78,9 @@ const ( ) var ( - // URL captures anything that looks like a URL. This includes - // URLs without a scheme, based on a built-in list of TLDs. - URL = xurls.Relaxed() + // URLLike captures anything that resembles a URL. This includes URLs + // with or without a scheme, and emails. + URLLike = xurls.Relaxed() // MentionName captures the username and domain part from // a mention string such as @whatever_user@example.org, diff --git a/internal/text/markdown.go b/internal/text/markdown.go index 96da9e57d..163996d77 100644 --- a/internal/text/markdown.go +++ b/internal/text/markdown.go @@ -139,7 +139,7 @@ func (f *Formatter) fromMarkdown( }, // Turns URLs into links. extension.NewLinkify( - extension.WithLinkifyURLRegexp(regexes.URL), + extension.WithLinkifyURLRegexp(regexes.URLLike), ), extension.Strikethrough, ), diff --git a/internal/text/plain.go b/internal/text/plain.go index 7176dfec7..17e2800ec 100644 --- a/internal/text/plain.go +++ b/internal/text/plain.go @@ -168,7 +168,7 @@ func (f *Formatter) fromPlain( }, // Turns URLs into links. extension.NewLinkify( - extension.WithLinkifyURLRegexp(regexes.URL), + extension.WithLinkifyURLRegexp(regexes.URLLike), ), ), )