mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
Render origin image on MSIE
This commit is contained in:
parent
14f99bfba3
commit
99f36b35f7
@ -61,7 +61,7 @@ func GenWebpAbs(RawImagePath string, ExhaustPath string, ImgFilename string, req
|
||||
return cwd, WebpAbsolutePath
|
||||
}
|
||||
|
||||
func isSafari(UA string) bool {
|
||||
func goOrigin(UA string) bool {
|
||||
// for more information, please check test case
|
||||
if strings.Contains(UA, "Firefox") || strings.Contains(UA, "Chrome") {
|
||||
// Chrome or firefox on macOS Windows
|
||||
@ -72,5 +72,9 @@ func isSafari(UA string) bool {
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
if strings.Contains(UA, "rv:11.0") || strings.Contains(UA, "MSIE") {
|
||||
// MSIE
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ func TestGenWebpAbs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestisSafari(t *testing.T) {
|
||||
func TestgoOrigin(t *testing.T) {
|
||||
// reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
|
||||
// https://developer.chrome.com/multidevice/user-agent#chrome_for_ios_user_agent
|
||||
|
||||
@ -89,7 +89,7 @@ func TestisSafari(t *testing.T) {
|
||||
|
||||
for browser, is := range testCase {
|
||||
|
||||
if is != isSafari(browser) {
|
||||
if is != goOrigin(browser) {
|
||||
t.Errorf("[%v]:[%s]", is, browser)
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ func Convert(ImgPath string, ExhaustPath string, AllowedTypes []string, QUALITY
|
||||
var ImgFilename = path.Base(reqURI) // pure filename, 123.jpg
|
||||
var finalFile string // We'll only need one c.sendFile()
|
||||
var UA = c.Get("User-Agent")
|
||||
done := isSafari(UA)
|
||||
done := goOrigin(UA)
|
||||
if done {
|
||||
log.Infof("A Safari user has arrived...%s", UA)
|
||||
log.Infof("A Safari/IE/whatever user has arrived...%s", UA)
|
||||
c.SendFile(RawImageAbs)
|
||||
return
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user