mirror of
https://github.com/stashapp/stash.git
synced 2026-04-22 06:52:39 +02:00
add conditionals to avoid url base duplication on stashbox submit (#3579)
This commit is contained in:
parent
5711ff6d21
commit
62a1bc22c9
1 changed files with 13 additions and 2 deletions
|
|
@ -10,6 +10,7 @@ import (
|
|||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
|
|
@ -1046,10 +1047,20 @@ func (c Client) SubmitPerformerDraft(ctx context.Context, performer *models.Perf
|
|||
|
||||
var urls []string
|
||||
if len(strings.TrimSpace(performer.Twitter)) > 0 {
|
||||
urls = append(urls, "https://twitter.com/"+strings.TrimSpace(performer.Twitter))
|
||||
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 {
|
||||
urls = append(urls, "https://instagram.com/"+strings.TrimSpace(performer.Instagram))
|
||||
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))
|
||||
|
|
|
|||
Loading…
Reference in a new issue