diff --git a/server/public/model/custom_profile_attributes.go b/server/public/model/custom_profile_attributes.go index ee7a3a74881..bf4103dd4f1 100644 --- a/server/public/model/custom_profile_attributes.go +++ b/server/public/model/custom_profile_attributes.go @@ -3,7 +3,10 @@ package model -import "errors" +import ( + "errors" + "strings" +) const CustomProfileAttributesPropertyGroupName = "custom_profile_attributes" @@ -35,8 +38,8 @@ type CustomProfileAttributesSelectOption struct { func NewCustomProfileAttributeSelectOption(name, color string) CustomProfileAttributesSelectOption { return CustomProfileAttributesSelectOption{ ID: NewId(), - Name: name, - Color: color, + Name: strings.TrimSpace(name), + Color: strings.TrimSpace(color), } } diff --git a/server/public/model/custom_profile_attributes_test.go b/server/public/model/custom_profile_attributes_test.go index 33e1dbc912c..2d4cea2393f 100644 --- a/server/public/model/custom_profile_attributes_test.go +++ b/server/public/model/custom_profile_attributes_test.go @@ -18,6 +18,13 @@ func TestNewCustomProfileAttributeSelectOption(t *testing.T) { assert.Equal(t, "Test Option", option.Name) assert.Equal(t, "#FF0000", option.Color) }) + + t.Run("trims spaces from name and color", func(t *testing.T) { + option := NewCustomProfileAttributeSelectOption(" Test Option ", " #FF0000 ") + + assert.Equal(t, "Test Option", option.Name) + assert.Equal(t, "#FF0000", option.Color) + }) } func TestCustomProfileAttributeSelectOptionIsValid(t *testing.T) {