mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-30 05:19:19 +00:00
Improving MIME type detection for some common file types when they are missing from the system MIME database
Also allow the user to specify their own database via mime.types in the kitty config directory. See #3056
This commit is contained in:
parent
e160cbf32b
commit
75a94bcd96
7 changed files with 62 additions and 13 deletions
|
|
@ -7,7 +7,7 @@ import re
|
|||
from contextlib import suppress
|
||||
from functools import lru_cache
|
||||
from hashlib import md5
|
||||
from mimetypes import guess_type
|
||||
from kitty.guess_mime_type import guess_type
|
||||
from typing import TYPE_CHECKING, Dict, List, Set, Optional, Iterator, Tuple, Union
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
|
@ -136,7 +136,7 @@ def sanitize(text: str) -> str:
|
|||
|
||||
@lru_cache(maxsize=1024)
|
||||
def mime_type_for_path(path: str) -> str:
|
||||
return guess_type(path)[0] or 'application/octet-stream'
|
||||
return guess_type(path) or 'application/octet-stream'
|
||||
|
||||
|
||||
@lru_cache(maxsize=1024)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue