From 3960c6678d52c16e1f699d34a72c3647125daa1a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 25 Oct 2020 15:11:44 +0530 Subject: [PATCH] Override MIME for some types that are actually text --- kitty/guess_mime_type.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kitty/guess_mime_type.py b/kitty/guess_mime_type.py index e5bb98475..9b3cd5964 100644 --- a/kitty/guess_mime_type.py +++ b/kitty/guess_mime_type.py @@ -19,6 +19,9 @@ known_extensions = { } +text_mimes = ('application/javascript', 'application/x-sh', 'application/json') + + def is_rc_file(path: str) -> bool: name = os.path.basename(path) return '.' not in name and name.endswith('rc') @@ -45,6 +48,8 @@ def guess_type(path: str) -> Optional[str]: if not mt: ext = path.rpartition('.')[-1].lower() mt = known_extensions.get(ext) + if mt in text_mimes: + mt = 'text/' + mt.split('/', 1)[-1] if not mt and is_rc_file(path): mt = 'text/plain' return mt