Skip to content

Commit

Permalink
fix(transport): disable avif when png (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
ykzts committed May 20, 2021
1 parent fc79165 commit c293444
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions transport.go
Expand Up @@ -72,14 +72,14 @@ func (t *Transport) makeRequest(r *http.Request) (*http.Request, error) {
return r2, nil
}

func scanAcceptHeader(r *http.Request) string {
func scanAcceptHeader(r *http.Request, t string) string {
f := os.Getenv("MANAEL_ENABLE_AVIF")
a := r.Header.Get("Accept")

for _, v := range strings.Split(a, ",") {
t := strings.TrimSpace(v)

if f == "true" && strings.HasPrefix(t, "image/avif") {
if f == "true" && t != "image/png" && strings.HasPrefix(t, "image/avif") {
return "image/avif"
} else if strings.HasPrefix(t, "image/webp") {
return "image/webp"
Expand Down Expand Up @@ -112,7 +112,7 @@ func check(w *http.Response, r *http.Request) string {
return "*/*"
}

return scanAcceptHeader(r)
return scanAcceptHeader(r, t)
}

func convert(src io.Reader, t string) (*bytes.Buffer, error) {
Expand Down

1 comment on commit c293444

@vercel
Copy link

@vercel vercel bot commented on c293444 May 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.