Skip to content

Commit

Permalink
use textproto.CanonicalMIMEHeaderKey to normalize headers
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidCai1111 committed Feb 20, 2017
1 parent c98dddd commit 3534a00
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions headers.go
@@ -1,6 +1,8 @@
package headers

import "unicode"
import (
"net/textproto"
)

// Version is this package's version
const Version = "2.1.0"
Expand Down Expand Up @@ -88,18 +90,5 @@ const (

// Normalize formats the input header to the formation of "Xxx-Xxx".
func Normalize(header string) string {
last := '-'
normalized := make([]rune, len(header))

for i, b := range header {
if last != '-' {
normalized[i] = unicode.ToLower(b)
} else {
normalized[i] = unicode.ToUpper(b)
}

last = b
}

return string(normalized)
return textproto.CanonicalMIMEHeaderKey(header)
}

0 comments on commit 3534a00

Please sign in to comment.