helper/variables: trim whitespace on key before empty string comp
This commit is contained in:
parent
b7f6f8eb2a
commit
6d594b3bc6
|
@ -21,6 +21,9 @@ func (v *Flag) Set(raw string) error {
|
|||
}
|
||||
|
||||
key, input := raw[0:idx], raw[idx+1:]
|
||||
|
||||
// Trim the whitespace on the key
|
||||
key = strings.TrimSpace(key)
|
||||
if key == "" {
|
||||
return fmt.Errorf("No key to left '=' in arg: %s", raw)
|
||||
}
|
||||
|
@ -30,9 +33,6 @@ func (v *Flag) Set(raw string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Trim the whitespace on the key
|
||||
key = strings.TrimSpace(key)
|
||||
|
||||
*v = Merge(*v, map[string]interface{}{key: value})
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -25,6 +25,12 @@ func TestFlag(t *testing.T) {
|
|||
true,
|
||||
},
|
||||
|
||||
{
|
||||
" =value",
|
||||
nil,
|
||||
true,
|
||||
},
|
||||
|
||||
{
|
||||
"key=value",
|
||||
map[string]interface{}{"key": "value"},
|
||||
|
|
Loading…
Reference in New Issue