From e718109638e9321f222f737940122598248fcd3d Mon Sep 17 00:00:00 2001 From: Drake Eidukas Date: Wed, 11 Dec 2024 16:50:33 -0800 Subject: [PATCH] fix: Handle case where data file has extra extension prefixes --- nominal/core/filetype.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nominal/core/filetype.py b/nominal/core/filetype.py index fb013c48..2cb0c3a4 100644 --- a/nominal/core/filetype.py +++ b/nominal/core/filetype.py @@ -23,8 +23,12 @@ def from_path(cls, path: Path | str, default_mimetype: str = "application/octect for file_type in FileTypes.__dict__.values(): if not isinstance(file_type, cls): continue + elif not file_type.extension: + continue - if file_type.extension.endswith(ext_str): + # If the file ends with the given file extension, regardless of other suffixes it may have + # preceeding, then return the file type. + if ext_str.endswith(file_type.extension): return file_type # Infer mimetype from filepath