mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-05-12 21:17:51 +00:00
Review fixes
This commit is contained in:
parent
1c0ce28d8e
commit
e34d5275d6
2 changed files with 8 additions and 13 deletions
|
@ -73,13 +73,12 @@ func AcceptEncodings(header string) []string {
|
|||
qualities := make(map[string]float64)
|
||||
|
||||
for _, encoding := range strings.Split(header, ",") {
|
||||
splits := strings.SplitN(encoding, ";q=", 2)
|
||||
name := splits[0]
|
||||
name, quality_str, has_quality := strings.Cut(encoding, ";q=")
|
||||
quality := 1.0
|
||||
|
||||
if len(splits) > 1 {
|
||||
if has_quality {
|
||||
var err error
|
||||
quality, err = strconv.ParseFloat(splits[1], 64)
|
||||
quality, err = strconv.ParseFloat(quality_str, 64)
|
||||
if err != nil || quality < 0 {
|
||||
continue
|
||||
}
|
||||
|
@ -120,7 +119,7 @@ func AcceptEncodings(header string) []string {
|
|||
// sort in reverse order; big quality comes first
|
||||
return cmp.Compare(qualities[y], qualities[x])
|
||||
})
|
||||
log.Trace().Msgf("decided encoding order: %#v", encodings)
|
||||
log.Trace().Msgf("decided encoding order: %v", encodings)
|
||||
return encodings
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue