Skip to content

Commit 6f639f2

Browse files
committed
Respect suffix map case lookup
1 parent 206be36 commit 6f639f2

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

Lib/mimetypes.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,14 @@ def guess_file_type(self, path, *, strict=True):
172172

173173
def _guess_file_type(self, path, strict, splitext):
174174
base, ext = splitext(path)
175-
while (ext_lower := ext.lower()) in self.suffix_map:
176-
base, ext = splitext(base + self.suffix_map[ext_lower])
175+
while True:
176+
if ext in self.suffix_map:
177+
suffix = self.suffix_map[ext]
178+
elif (ext_lower := ext.lower()) in self.suffix_map:
179+
suffix = self.suffix_map[ext_lower]
180+
else:
181+
break
182+
base, ext = splitext(base + suffix)
177183
# encodings_map is case sensitive
178184
if ext in self.encodings_map:
179185
encoding = self.encodings_map[ext]

0 commit comments

Comments
 (0)