mirror of
https://github.com/stashapp/stash.git
synced 2025-12-16 20:07:05 +03:00
Bugfix: Add Trimspace to New Objects (#6226)
This commit is contained in:
@@ -30,7 +30,7 @@ func (ScrapedStudio) IsScrapedContent() {}
|
||||
func (s *ScrapedStudio) ToStudio(endpoint string, excluded map[string]bool) *Studio {
|
||||
// Populate a new studio from the input
|
||||
ret := NewStudio()
|
||||
ret.Name = s.Name
|
||||
ret.Name = strings.TrimSpace(s.Name)
|
||||
|
||||
if s.RemoteSiteID != nil && endpoint != "" {
|
||||
ret.StashIDs = NewRelatedStashIDs([]StashID{
|
||||
@@ -95,37 +95,38 @@ func (s *ScrapedStudio) ToPartial(id string, endpoint string, excluded map[strin
|
||||
currentTime := time.Now()
|
||||
|
||||
if s.Name != "" && !excluded["name"] {
|
||||
ret.Name = NewOptionalString(s.Name)
|
||||
ret.Name = NewOptionalString(strings.TrimSpace(s.Name))
|
||||
}
|
||||
|
||||
if len(s.URLs) > 0 {
|
||||
if !excluded["urls"] {
|
||||
|
||||
ret.URLs = &UpdateStrings{
|
||||
Values: s.URLs,
|
||||
Values: stringslice.TrimSpace(s.URLs),
|
||||
Mode: RelationshipUpdateModeSet,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
urls := []string{}
|
||||
if s.URL != nil && !excluded["url"] {
|
||||
urls = append(urls, *s.URL)
|
||||
urls = append(urls, strings.TrimSpace(*s.URL))
|
||||
}
|
||||
|
||||
if len(urls) > 0 {
|
||||
ret.URLs = &UpdateStrings{
|
||||
Values: urls,
|
||||
Values: stringslice.TrimSpace(urls),
|
||||
Mode: RelationshipUpdateModeSet,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if s.Details != nil && !excluded["details"] {
|
||||
ret.Details = NewOptionalString(*s.Details)
|
||||
ret.Details = NewOptionalString(strings.TrimSpace(*s.Details))
|
||||
}
|
||||
|
||||
if s.Aliases != nil && !excluded["aliases"] {
|
||||
ret.Aliases = &UpdateStrings{
|
||||
Values: stringslice.FromString(*s.Aliases, ","),
|
||||
Values: stringslice.TrimSpace(stringslice.FromString(*s.Aliases, ",")),
|
||||
Mode: RelationshipUpdateModeSet,
|
||||
}
|
||||
}
|
||||
@@ -197,10 +198,14 @@ func (ScrapedPerformer) IsScrapedContent() {}
|
||||
func (p *ScrapedPerformer) ToPerformer(endpoint string, excluded map[string]bool) *Performer {
|
||||
ret := NewPerformer()
|
||||
currentTime := time.Now()
|
||||
ret.Name = *p.Name
|
||||
ret.Name = strings.TrimSpace(*p.Name)
|
||||
|
||||
if p.Aliases != nil && !excluded["aliases"] {
|
||||
ret.Aliases = NewRelatedStrings(stringslice.FromString(*p.Aliases, ","))
|
||||
aliases := stringslice.FromString(*p.Aliases, ",")
|
||||
for i, alias := range aliases {
|
||||
aliases[i] = strings.TrimSpace(alias)
|
||||
}
|
||||
ret.Aliases = NewRelatedStrings(aliases)
|
||||
}
|
||||
if p.Birthdate != nil && !excluded["birthdate"] {
|
||||
date, err := ParseDate(*p.Birthdate)
|
||||
|
||||
@@ -44,3 +44,11 @@ func UniqueFold(s []string) []string {
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// TrimSpace trims whitespace from each string in a slice.
|
||||
func TrimSpace(s []string) []string {
|
||||
for i, v := range s {
|
||||
s[i] = strings.TrimSpace(v)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user