mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
Add another UA for original image (#40)
This commit is contained in:
parent
8784918f8e
commit
acb020fb7a
@ -1,13 +1,14 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/gofiber/fiber"
|
"github.com/gofiber/fiber"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -18,10 +19,9 @@ func Convert(ImgPath string, ExhaustPath string, AllowedTypes []string, QUALITY
|
|||||||
var RawImageAbs = path.Join(ImgPath, reqURI) // /home/xxx/mypic/123.jpg
|
var RawImageAbs = path.Join(ImgPath, reqURI) // /home/xxx/mypic/123.jpg
|
||||||
var ImgFilename = path.Base(reqURI) // pure filename, 123.jpg
|
var ImgFilename = path.Base(reqURI) // pure filename, 123.jpg
|
||||||
var finalFile string // We'll only need one c.sendFile()
|
var finalFile string // We'll only need one c.sendFile()
|
||||||
// Check for Safari users. If they're Safari, just simply ignore everything.
|
// Check for Safari users. If they're Safari or the UA contains `AppleWebKit`(Might be the WeChat Browser), just simply ignore everything.
|
||||||
UA := c.Get("User-Agent")
|
UA := c.Get("User-Agent")
|
||||||
if strings.Contains(UA, "Safari") && !strings.Contains(UA, "Chrome") &&
|
if (strings.Contains(UA, "Safari") && !strings.Contains(UA, "Chrome") && !strings.Contains(UA, "Firefox")) || (strings.Contains(UA, "AppleWebKit")) {
|
||||||
!strings.Contains(UA, "Firefox") {
|
|
||||||
log.Info("A Safari user has arrived...")
|
log.Info("A Safari user has arrived...")
|
||||||
c.SendFile(RawImageAbs)
|
c.SendFile(RawImageAbs)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user