diff options
author | Wim <wim@42.be> | 2020-12-31 14:48:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-31 14:48:12 +0100 |
commit | 4f20ebead36876a88391bf033d1de3e4cf0228da (patch) | |
tree | 70b6fd79c6a5e00c958c29a7bd3926f074e76ba6 /vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/autolink.go | |
parent | a9f89dbc645aafc68daa9fc8d589f55104b535c7 (diff) | |
download | matterbridge-msglm-4f20ebead36876a88391bf033d1de3e4cf0228da.tar.gz matterbridge-msglm-4f20ebead36876a88391bf033d1de3e4cf0228da.tar.bz2 matterbridge-msglm-4f20ebead36876a88391bf033d1de3e4cf0228da.zip |
Update vendor for next release (#1343)
Diffstat (limited to 'vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/autolink.go')
-rw-r--r-- | vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/autolink.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/autolink.go b/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/autolink.go index 14180836..d06ada66 100644 --- a/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/autolink.go +++ b/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/autolink.go @@ -14,6 +14,7 @@ import ( var ( DefaultUrlSchemes = []string{"http", "https", "ftp", "mailto", "tel"} + wwwAutoLinkRegex = regexp.MustCompile(`^www\d{0,3}\.`) ) // Given a string with a w at the given position, tries to parse and return a range containing a www link. @@ -30,7 +31,7 @@ func parseWWWAutolink(data string, position int) (Range, bool) { } // Check that this starts with www - if len(data)-position < 4 || !regexp.MustCompile(`^www\d{0,3}\.`).MatchString(data[position:]) { + if len(data)-position < 4 || !wwwAutoLinkRegex.MatchString(data[position:]) { return Range{}, false } @@ -59,9 +60,8 @@ func isAllowedBeforeWWWLink(c byte) bool { switch c { case '*', '_', '~', ')': return true - default: - return false } + return false } // Given a string with a : at the given position, tried to parse and return a range containing a URL scheme @@ -153,9 +153,8 @@ func checkDomain(data string, allowShort bool) int { // this is called from parseWWWAutolink if foundPeriod { return i - } else { - return 0 } + return 0 } // Returns true if the provided link starts with a valid character for a domain name. Equivalent to @@ -251,7 +250,6 @@ func canEndAutolink(c rune) bool { switch c { case '?', '!', '.', ',', ':', '*', '_', '~', '\'', '"': return false - default: - return true } + return true } |