Skip to content

Commit

Permalink
Merge pull request goji#3 from thatguystone/master
Browse files Browse the repository at this point in the history
Fix 'index out of range' error
  • Loading branch information
zenazn committed Jun 1, 2016
2 parents da86c81 + 676747a commit 0b4aa9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions param_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,10 @@ func TestStructErrors(t *testing.T) {
t.Error("expected error parsing struct without key")
}

if _, ok := err.(SyntaxError); !ok {
t.Error("expected SyntaxError parsing struct without key")
}

err = Parse(url.Values{"Struct[": {"llama"}}, &e)
if err == nil {
t.Error("expected error parsing malformed struct key")
Expand Down
2 changes: 1 addition & 1 deletion parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func primitive(key, keytail string, tipe reflect.Type, values []string) {
}

func keyed(tipe reflect.Type, key, keytail string) (string, string) {
if keytail[0] != '[' {
if keytail == "" || keytail[0] != '[' {
panic(SyntaxError{
Key: kpath(key, keytail),
Subtype: MissingOpeningBracket,
Expand Down

0 comments on commit 0b4aa9f

Please sign in to comment.