Skip to content

Commit 3dc7f92

Browse files
committed
perf(acceptHeaders): parse header only if exists
1 parent 898150e commit 3dc7f92

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/acceptHeaders/accepts.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ func (accepts Accepts) GetPreferredValue(availables []string) (index int, value
3434
func ParseAccepts(input string) Accepts {
3535
entries := strings.Split(input, ",")
3636
entryCount := len(entries)
37+
if entryCount == 0 {
38+
return nil
39+
}
40+
3741
accepts := make(Accepts, entryCount)
3842
for i := 0; i < entryCount; i++ {
3943
accepts[i] = parseAcceptItem(strings.TrimSpace(entries[i]))

0 commit comments

Comments
 (0)