mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
add conditionals to avoid url base duplication on stashbox submit (#3579)
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -1046,11 +1047,21 @@ func (c Client) SubmitPerformerDraft(ctx context.Context, performer *models.Perf
|
||||
|
||||
var urls []string
|
||||
if len(strings.TrimSpace(performer.Twitter)) > 0 {
|
||||
reg := regexp.MustCompile(`https?:\/\/(?:www\.)?twitter\.com`)
|
||||
if reg.MatchString(performer.Twitter) {
|
||||
urls = append(urls, strings.TrimSpace(performer.Twitter))
|
||||
} else {
|
||||
urls = append(urls, "https://twitter.com/"+strings.TrimSpace(performer.Twitter))
|
||||
}
|
||||
}
|
||||
if len(strings.TrimSpace(performer.Instagram)) > 0 {
|
||||
reg := regexp.MustCompile(`https?:\/\/(?:www\.)?instagram\.com`)
|
||||
if reg.MatchString(performer.Instagram) {
|
||||
urls = append(urls, strings.TrimSpace(performer.Instagram))
|
||||
} else {
|
||||
urls = append(urls, "https://instagram.com/"+strings.TrimSpace(performer.Instagram))
|
||||
}
|
||||
}
|
||||
if len(strings.TrimSpace(performer.URL)) > 0 {
|
||||
urls = append(urls, strings.TrimSpace(performer.URL))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user