Skip to content

Commit

Permalink
Correctly handle zero length values
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Kalafut committed Feb 12, 2020
1 parent 40e9485 commit 8540377
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion http/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,8 @@ func parseFormRequest(r *http.Request) (map[string]interface{}, error) {
data = make(map[string]interface{}, len(r.PostForm))
for k, v := range r.PostForm {
switch len(v) {
case 0, 1:
case 0:
case 1:
data[k] = v[0]
default:
// Almost anywhere taking in a string list can take in comma
Expand Down
1 change: 1 addition & 0 deletions http/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ func TestHandler_Parse_Form(t *testing.T) {
"zip": []string{"zap"},
"abc": []string{"xyz"},
"multi": []string{"first", "second"},
"empty": []string{},
}
req, err := http.NewRequest("POST", cores[0].Client.Address()+"/v1/secret/foo", nil)
if err != nil {
Expand Down

0 comments on commit 8540377

Please sign in to comment.