mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-24 05:43:32 -06:00
Merge branch 'main' into add_gallery_web_rendering_mode
This commit is contained in:
commit
974e710f63
151 changed files with 4644 additions and 18506 deletions
|
|
@ -21,7 +21,7 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/go-viper/mapstructure/v2"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
"regexp"
|
||||
"sync"
|
||||
|
||||
"mvdan.cc/xurls/v2"
|
||||
xurls "mvdan.cc/xurls/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -40,7 +40,6 @@ const (
|
|||
reports = "reports"
|
||||
accepts = "accepts"
|
||||
|
||||
schemes = `(http|https)://` // Allowed URI protocols for parsing links in text.
|
||||
alphaNumeric = `\p{L}\p{M}*|\p{N}` // A single number or script character in any language, including chars with accents.
|
||||
usernameGrp = `(?:` + alphaNumeric + `|\.|\-|\_)` // Non-capturing group that matches against a single valid username character.
|
||||
domainGrp = `(?:` + alphaNumeric + `|\.|\-|\:)` // Non-capturing group that matches against a single valid domain character.
|
||||
|
|
@ -79,14 +78,9 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
// LinkScheme captures http/https schemes in URLs.
|
||||
LinkScheme = func() *regexp.Regexp {
|
||||
rgx, err := xurls.StrictMatchingScheme(schemes)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return rgx
|
||||
}()
|
||||
// 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,
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ func (f *Formatter) fromMarkdown(
|
|||
},
|
||||
// Turns URLs into links.
|
||||
extension.NewLinkify(
|
||||
extension.WithLinkifyURLRegexp(regexes.LinkScheme),
|
||||
extension.WithLinkifyURLRegexp(regexes.URLLike),
|
||||
),
|
||||
extension.Strikethrough,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ func (f *Formatter) fromPlain(
|
|||
},
|
||||
// Turns URLs into links.
|
||||
extension.NewLinkify(
|
||||
extension.WithLinkifyURLRegexp(regexes.LinkScheme),
|
||||
extension.WithLinkifyURLRegexp(regexes.URLLike),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue