mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Finish implementation of clipboard writing
This commit is contained in:
24
tools/utils/mimetypes.go
Normal file
24
tools/utils/mimetypes.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"mime"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
func GuessMimeType(filename string) string {
|
||||
ext := filepath.Ext(filename)
|
||||
mime_with_parameters := mime.TypeByExtension(ext)
|
||||
if mime_with_parameters == "" {
|
||||
return mime_with_parameters
|
||||
}
|
||||
ans, _, err := mime.ParseMediaType(mime_with_parameters)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return ans
|
||||
}
|
||||
Reference in New Issue
Block a user