Skip to content

Commit

Permalink
feat(form): add array collection format in form binding
Browse files Browse the repository at this point in the history
  • Loading branch information
slowhigh committed Aug 15, 2024
1 parent 78822bf commit b8cfe5a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion binding/form_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ func trySplit(vs []string, field reflect.StructField) (newVs []string, err error
return vs, fmt.Errorf("%s is not supported in the collection_format. (csv, ssv, pipes)", cfTag)
}

newVs = make([]string, 0)
totalLength := 0
for _, v := range vs {
totalLength += strings.Count(v, sep) + 1
}
newVs = make([]string, 0, totalLength)
for _, v := range vs {
newVs = append(newVs, strings.Split(v, sep)...)
}
Expand Down

0 comments on commit b8cfe5a

Please sign in to comment.