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:
@@ -17,6 +17,7 @@ from .config import KeyAction, parse_key_action
|
||||
from .constants import config_dir
|
||||
from .typing import MatchType
|
||||
from .utils import expandvars, log_error
|
||||
from .guess_mime_type import guess_type
|
||||
|
||||
|
||||
class MatchCriteria(NamedTuple):
|
||||
@@ -75,12 +76,8 @@ def url_matches_criterion(purl: 'ParseResult', url: str, unquoted_path: str, mc:
|
||||
|
||||
if mc.type == 'mime':
|
||||
import fnmatch
|
||||
from mimetypes import guess_type
|
||||
try:
|
||||
mt = guess_type(unquoted_path)[0]
|
||||
except Exception:
|
||||
return False
|
||||
if mt is None:
|
||||
mt = guess_type(unquoted_path)
|
||||
if not mt:
|
||||
return False
|
||||
mt = mt.lower()
|
||||
for mpat in mc.value.split(','):
|
||||
|
||||
Reference in New Issue
Block a user