Skip to content

Commit

Permalink
fix quotes trimmed even if not at START and END
Browse files Browse the repository at this point in the history
  • Loading branch information
Misfits09 authored and schmurfy committed Apr 29, 2024
1 parent ce2d196 commit 7472649
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions wrapper/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ func convertValue(fieldType reflect.Type, value string) (reflect.Value, error) {
return setValue.Elem(), nil

case reflect.String:
return reflect.ValueOf(
strings.Trim(value, `"`),
).Convert(fieldType), nil
trimed := value
if len(trimed) > 2 && trimed[0] == '"' && trimed[len(trimed)-1] == '"' {
trimed = trimed[1 : len(trimed)-1] // remove quotes only if they are at the beginning AND the end
}
return reflect.ValueOf(trimed).Convert(fieldType), nil

case reflect.Bool:
setValue, err := strconv.ParseBool(value)
Expand Down

0 comments on commit 7472649

Please sign in to comment.