Skip to content

Commit

Permalink
* allow underscores on headers. (#19)
Browse files Browse the repository at this point in the history
* fix spelling mistakes
* fix a header not being tested
  • Loading branch information
ted-marozzi committed Apr 19, 2022
1 parent 9b0b248 commit 318c905
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion utils.go
Expand Up @@ -51,7 +51,7 @@ func parseHeaderList(headerList string) []string {
} else {
h = append(h, b)
}
} else if b == '-' || (b >= '0' && b <= '9') {
} else if b == '-' || b == '_' || (b >= '0' && b <= '9') {
h = append(h, b)
}

Expand Down
10 changes: 5 additions & 5 deletions utils_test.go
Expand Up @@ -32,19 +32,19 @@ func TestConvert(t *testing.T) {
}

func TestParseHeaderList(t *testing.T) {
h := parseHeaderList("header, second-header, THIRD-HEADER, Numb3r3d-H34d3r")
e := []string{"Header", "Second-Header", "Third-Header", "Numb3r3d-H34d3r"}
if h[0] != e[0] || h[1] != e[1] || h[2] != e[2] {
h := parseHeaderList("header, second-header, THIRD-HEADER, Numb3r3d-H34d3r, Header_with_underscore")
e := []string{"Header", "Second-Header", "Third-Header", "Numb3r3d-H34d3r", "Header_with_underscore"}
if h[0] != e[0] || h[1] != e[1] || h[2] != e[2] || h[3] != e[3] || h[4] != e[4] {
t.Errorf("%v != %v", h, e)
}
}

func TestParseHeaderListEmpty(t *testing.T) {
if len(parseHeaderList("")) != 0 {
t.Error("should be empty sclice")
t.Error("should be empty slice")
}
if len(parseHeaderList(" , ")) != 0 {
t.Error("should be empty sclice")
t.Error("should be empty slice")
}
}

Expand Down

0 comments on commit 318c905

Please sign in to comment.