mirror of
https://git.maid.zone/stuff/soundcloak.git
synced 2025-12-12 06:39:38 +05:00
Get links to other places in user profiles; other small improvements
This commit is contained in:
@@ -11,10 +11,15 @@ import (
|
||||
//var wordre = regexp.MustCompile(`\S+`)
|
||||
|
||||
// var urlre = regexp.MustCompile(`https?:\/\/[-a-zA-Z0-9@%._\+~#=]{2,256}\.[a-z]{1,6}[-a-zA-Z0-9@:%_\+.~#?&\/\/=]*`)
|
||||
// var emailre = regexp.MustCompile(`[-a-zA-Z0-9%._\+~#=]+@[-a-zA-Z0-9%._\+~=&]{2,256}\.[a-z]{1,6}`)
|
||||
var emailre = regexp.MustCompile(`^[-a-zA-Z0-9%._\+~#=]+@[-a-zA-Z0-9%._\+~=&]{2,256}\.[a-z]{1,6}$`)
|
||||
|
||||
// var usernamere = regexp.MustCompile(`@[a-zA-Z0-9\-]+`)
|
||||
var theregex = regexp.MustCompile(`@[a-zA-Z0-9\-]+|(?:https?:\/\/[-a-zA-Z0-9@%._\+~#=]{2,256}\.[a-z]{1,6}[-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)|(?:[-a-zA-Z0-9%._\+~#=]+@[-a-zA-Z0-9%._\+~=&]{2,256}\.[a-z]{1,6})`)
|
||||
|
||||
func IsEmail(s string) bool {
|
||||
return emailre.MatchString(s)
|
||||
}
|
||||
|
||||
func replacer(ent string) string {
|
||||
if strings.HasPrefix(ent, "@") {
|
||||
return fmt.Sprintf(`<a class="link" href="/%s">%s</a>`, ent[1:], ent)
|
||||
@@ -27,6 +32,9 @@ func replacer(ent string) string {
|
||||
href := ent
|
||||
if parsed.Host == "soundcloud.com" || strings.HasSuffix(parsed.Host, ".soundcloud.com") {
|
||||
href = "/" + strings.Join(strings.Split(ent, "/")[3:], "/")
|
||||
if parsed.Host == "on.soundcloud.com" {
|
||||
href = "/on" + href
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Sprintf(`<a class="link" href="%s" referrerpolicy="no-referrer" rel="external nofollow noopener noreferrer ugc" target="_blank">%s</a>`, href, ent)
|
||||
|
||||
Reference in New Issue
Block a user