mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
parent
30deec4224
commit
4a89508b50
1 changed files with 8 additions and 9 deletions
|
|
@ -3,7 +3,6 @@ package assetserver
|
|||
import (
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/gabriel-vasile/mimetype"
|
||||
|
|
@ -18,6 +17,14 @@ func GetMimetype(filename string, data []byte) string {
|
|||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
|
||||
if filepath.Ext(filename) == ".js" {
|
||||
return "application/javascript"
|
||||
}
|
||||
|
||||
if filepath.Ext(filename) == ".css" {
|
||||
return "text/css"
|
||||
}
|
||||
|
||||
result := cache[filename]
|
||||
if result != "" {
|
||||
return result
|
||||
|
|
@ -30,14 +37,6 @@ func GetMimetype(filename string, data []byte) string {
|
|||
result = detect.String()
|
||||
}
|
||||
|
||||
if filepath.Ext(filename) == ".css" && strings.HasPrefix(result, "text/plain") {
|
||||
result = strings.Replace(result, "text/plain", "text/css", 1)
|
||||
}
|
||||
|
||||
if filepath.Ext(filename) == ".js" && strings.HasPrefix(result, "text/plain") {
|
||||
result = strings.Replace(result, "text/plain", "text/javascript", 1)
|
||||
}
|
||||
|
||||
if result == "" {
|
||||
result = "application/octet-stream"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue