use strings.Split instead of strings.IndexByte

This commit is contained in:
thinkerou 2018-06-20 21:31:26 +08:00
parent caf3e350a5
commit 7e16315747

View File

@ -103,10 +103,7 @@ func parseAccept(acceptHeader string) []string {
parts := strings.Split(acceptHeader, ",") parts := strings.Split(acceptHeader, ",")
out := make([]string, 0, len(parts)) out := make([]string, 0, len(parts))
for _, part := range parts { for _, part := range parts {
if index := strings.IndexByte(part, ';'); index >= 0 { if part = strings.TrimSpace(strings.Split(part, ";")[0]); part != "" {
part = part[0:index]
}
if part = strings.TrimSpace(part); part != "" {
out = append(out, part) out = append(out, part)
} }
} }