Render origin image on MSIE

This commit is contained in:
n0vad3v 2020-06-30 16:12:35 +08:00
parent 14f99bfba3
commit 99f36b35f7
No known key found for this signature in database
GPG Key ID: 8D42A0E699E50639
3 changed files with 9 additions and 5 deletions

View File

@ -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
}

View File

@ -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)
}
}

View File

@ -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
}