mirror of
https://github.com/distribution/distribution.git
synced 2026-07-16 16:59:52 +00:00
refactor: use slices.Backward to simplify the code
Signed-off-by: chuanshanjida <chuanshanjida@outlook.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"math"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
@@ -256,8 +257,8 @@ func (hrs *HTTPReadSeeker) reader() (_ io.Reader, retErr error) {
|
||||
encoding := strings.FieldsFunc(resp.Header.Get("Content-Encoding"), func(r rune) bool {
|
||||
return unicode.IsSpace(r) || r == ','
|
||||
})
|
||||
for i := len(encoding) - 1; i >= 0; i-- {
|
||||
algorithm := strings.ToLower(encoding[i])
|
||||
for _, v := range slices.Backward(encoding) {
|
||||
algorithm := strings.ToLower(v)
|
||||
switch algorithm {
|
||||
case "zstd":
|
||||
r, err := zstd.NewReader(body)
|
||||
|
||||
Reference in New Issue
Block a user