Skip to content

Commit 083b860

Browse files
Refactor main.py: Update text MIME type checking logic to include additional MIME types for better accuracy
1 parent 1f71cd7 commit 083b860

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

extliner/main.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,27 @@
77
from typing import Dict, List, Optional, Tuple, Union
88
from concurrent.futures import ProcessPoolExecutor, as_completed
99

10+
11+
TEXT_LIKE_MIME_TYPES = {
12+
"application/json",
13+
"application/javascript",
14+
"application/xml",
15+
"application/xhtml+xml",
16+
"application/x-www-form-urlencoded",
17+
"application/csv",
18+
"application/yaml",
19+
"application/x-yaml",
20+
"application/atom+xml",
21+
"application/rss+xml"
22+
}
23+
1024
def is_text_mimetype(path: str) -> bool:
1125
mime, _ = mimetypes.guess_type(path)
12-
return mime is not None and (mime.startswith("text/") or mime == "application/json")
26+
return (
27+
mime is not None and (
28+
mime.startswith("text/") or mime in TEXT_LIKE_MIME_TYPES
29+
)
30+
)
1331

1432
def process_file(filepath: str, encoding: str) -> Optional[Tuple[str, int, int]]:
1533
ext = (Path(filepath).suffix or "NO_EXT").lower()

0 commit comments

Comments
 (0)