Skip to content

Commit

Permalink
Fix bracket handling in StringToString (spf13#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
lstemplinger committed Sep 20, 2024
1 parent d5e0c06 commit aaacefa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion string_to_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ func (s *stringToStringValue) String() string {
}

func stringToStringConv(val string) (interface{}, error) {
val = strings.Trim(val, "[]")
if strings.HasPrefix(val, "[") && strings.HasSuffix(val, "]") {
val = strings.TrimPrefix(val, "[")
val = strings.TrimSuffix(val, "]")
}
// An empty string would cause an empty map
if len(val) == 0 {
return map[string]string{}, nil
Expand Down

0 comments on commit aaacefa

Please sign in to comment.