Skip to content

Commit

Permalink
feat(transprot): add flag for avif (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
ykzts committed May 14, 2021
1 parent c600bdb commit 37cea0f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion transport.go
Expand Up @@ -29,6 +29,7 @@ import (
"net"
"net/http"
"net/url"
"os"
"path"
"strconv"
"strings"
Expand Down Expand Up @@ -72,12 +73,13 @@ func (t *Transport) makeRequest(r *http.Request) (*http.Request, error) {
}

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

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

if strings.HasPrefix(t, "image/avif") {
if f == "true" && strings.HasPrefix(t, "image/avif") {
return "image/avif"
} else if strings.HasPrefix(t, "image/webp") {
return "image/webp"
Expand Down

1 comment on commit 37cea0f

@vercel
Copy link

@vercel vercel bot commented on 37cea0f May 14, 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.