diff --git a/README.md b/README.md index b1dd51c..16ac364 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ your files are at `/var/www/image/pics/tsuki.jpg`, then `IMG_PATH` shall be `/va 3. Let Nginx to `proxy_pass http://localhost:3333/;` ## TODO -- [ ] This version doesn't support header-based-output, which means Safari users will not see the converted `webp` images, this should be fixed in later releases. +- [x] This version doesn't support header-based-output, which means Safari users will not see the converted `webp` images, this should be fixed in later releases. - [ ] Multi platform support. ## build your own binary diff --git a/webp_server.go b/webp_server.go index d743adb..317fe68 100644 --- a/webp_server.go +++ b/webp_server.go @@ -123,6 +123,13 @@ func main() { return } + // Check for Safari users + UA := c.Get("User-Agent") + if strings.Contains(UA,"Safari") && !strings.Contains(UA,"Chrome") && !strings.Contains(UA,"Firefox"){ + c.SendFile(ImgAbsolutePath) + return + } + if imageExists(WebpAbsolutePath) { c.SendFile(WebpAbsolutePath) } else {