@@ -86,6 +86,9 @@ def add_type(self, type, ext, strict=True):
8686 is already known the extension will be added
8787 to the list of known extensions.
8888
89+ Registered lower-case extensions are matched
90+ case-insensitively.
91+
8992 If strict is true, information will be added to
9093 list of standard types, else to the list of non-standard
9194 types.
@@ -172,23 +175,33 @@ def guess_file_type(self, path, *, strict=True):
172175
173176 def _guess_file_type (self , path , strict , splitext ):
174177 base , ext = splitext (path )
175- while (ext_lower := ext .lower ()) in self .suffix_map :
176- base , ext = splitext (base + self .suffix_map [ext_lower ])
178+ while True :
179+ if ext in self .suffix_map :
180+ suffix = self .suffix_map [ext ]
181+ elif (ext_lower := ext .lower ()) in self .suffix_map :
182+ suffix = self .suffix_map [ext_lower ]
183+ else :
184+ break
185+ base , ext = splitext (base + suffix )
177186 # encodings_map is case sensitive
178187 if ext in self .encodings_map :
179188 encoding = self .encodings_map [ext ]
180189 base , ext = splitext (base )
181190 else :
182191 encoding = None
183- ext = ext .lower ()
192+ ext_lower = ext .lower ()
184193 types_map = self .types_map [True ]
185194 if ext in types_map :
186195 return types_map [ext ], encoding
196+ if ext_lower in types_map :
197+ return types_map [ext_lower ], encoding
187198 elif strict :
188199 return None , encoding
189200 types_map = self .types_map [False ]
190201 if ext in types_map :
191202 return types_map [ext ], encoding
203+ if ext_lower in types_map :
204+ return types_map [ext_lower ], encoding
192205 else :
193206 return None , encoding
194207
@@ -386,6 +399,9 @@ def add_type(type, ext, strict=True):
386399 is already known the extension will be added
387400 to the list of known extensions.
388401
402+ Registered lower-case extensions are matched
403+ case-insensitively.
404+
389405 If strict is true, information will be added to
390406 list of standard types, else to the list of non-standard
391407 types.
0 commit comments