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"
|
"io"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -1046,11 +1047,21 @@ func (c Client) SubmitPerformerDraft(ctx context.Context, performer *models.Perf
|
|||||||
|
|
||||||
var urls []string
|
var urls []string
|
||||||
if len(strings.TrimSpace(performer.Twitter)) > 0 {
|
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))
|
urls = append(urls, "https://twitter.com/"+strings.TrimSpace(performer.Twitter))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(strings.TrimSpace(performer.Instagram)) > 0 {
|
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))
|
urls = append(urls, "https://instagram.com/"+strings.TrimSpace(performer.Instagram))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(strings.TrimSpace(performer.URL)) > 0 {
|
if len(strings.TrimSpace(performer.URL)) > 0 {
|
||||||
urls = append(urls, strings.TrimSpace(performer.URL))
|
urls = append(urls, strings.TrimSpace(performer.URL))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user