mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 08:47:47 +02:00
kitten: When guessing MIME types use a builtin list as a fallback, generated from the MIME type definitions available on the build system
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"mime"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
@@ -14,7 +15,14 @@ func GuessMimeType(filename string) string {
|
||||
ext := filepath.Ext(filename)
|
||||
mime_with_parameters := mime.TypeByExtension(ext)
|
||||
if mime_with_parameters == "" {
|
||||
return mime_with_parameters
|
||||
only_once.Do(set_builtins)
|
||||
mime_with_parameters = builtin_types_map[ext]
|
||||
if mime_with_parameters == "" {
|
||||
mime_with_parameters = builtin_types_map[strings.ToLower(ext)]
|
||||
if mime_with_parameters == "" {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
}
|
||||
ans, _, err := mime.ParseMediaType(mime_with_parameters)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user