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
|
return cwd, WebpAbsolutePath
|
||||||
}
|
}
|
||||||
|
|
||||||
func isSafari(UA string) bool {
|
func goOrigin(UA string) bool {
|
||||||
// for more information, please check test case
|
// for more information, please check test case
|
||||||
if strings.Contains(UA, "Firefox") || strings.Contains(UA, "Chrome") {
|
if strings.Contains(UA, "Firefox") || strings.Contains(UA, "Chrome") {
|
||||||
// Chrome or firefox on macOS Windows
|
// Chrome or firefox on macOS Windows
|
||||||
@ -72,5 +72,9 @@ func isSafari(UA string) bool {
|
|||||||
} else {
|
} else {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if strings.Contains(UA, "rv:11.0") || strings.Contains(UA, "MSIE") {
|
||||||
|
// MSIE
|
||||||
|
return true
|
||||||
|
}
|
||||||
return false
|
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
|
// 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
|
// 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 {
|
for browser, is := range testCase {
|
||||||
|
|
||||||
if is != isSafari(browser) {
|
if is != goOrigin(browser) {
|
||||||
t.Errorf("[%v]:[%s]", is, 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 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()
|
||||||
var UA = c.Get("User-Agent")
|
var UA = c.Get("User-Agent")
|
||||||
done := isSafari(UA)
|
done := goOrigin(UA)
|
||||||
if done {
|
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)
|
c.SendFile(RawImageAbs)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user