Skip to content

Commit 232c7e4

Browse files
committed
fix: prevent panic on empty key
1 parent 891fce5 commit 232c7e4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

types/mapping.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (m *MappingWithEquals) DecodeMapstructure(value interface{}) error {
9595
mapping := make(MappingWithEquals, len(v))
9696
for _, s := range v {
9797
k, e, ok := strings.Cut(fmt.Sprint(s), "=")
98-
if unicode.IsSpace(rune(k[len(k)-1])) {
98+
if k != "" && unicode.IsSpace(rune(k[len(k)-1])) {
9999
return fmt.Errorf("environment variable %s is declared with a trailing space", k)
100100
}
101101
if !ok {

0 commit comments

Comments
 (0)