From 62a1bc22c997e9c42da6a4a5feece09c96cd5506 Mon Sep 17 00:00:00 2001 From: halorrr Date: Mon, 17 Apr 2023 01:30:00 -0400 Subject: [PATCH] add conditionals to avoid url base duplication on stashbox submit (#3579) --- pkg/scraper/stashbox/stash_box.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/scraper/stashbox/stash_box.go b/pkg/scraper/stashbox/stash_box.go index 9d8e65d0c..b8eadfd1b 100644 --- a/pkg/scraper/stashbox/stash_box.go +++ b/pkg/scraper/stashbox/stash_box.go @@ -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))