From a5543528ba175708e55090fdc6703347a990665b Mon Sep 17 00:00:00 2001 From: JB Date: Mon, 13 Oct 2025 15:10:55 -0700 Subject: [PATCH] feat: Normalize base directory handling in EPUB path normalization --- abogen/web/routes.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/abogen/web/routes.py b/abogen/web/routes.py index 4e3edb7..c7c20bd 100644 --- a/abogen/web/routes.py +++ b/abogen/web/routes.py @@ -151,6 +151,14 @@ def _normalize_epub_path(base_dir: str, href: str) -> str: if sanitized.startswith("/"): sanitized = sanitized[1:] base_dir = "" + normalized_base = base_dir.strip("/") + sanitized_lower = sanitized.lower() + if normalized_base: + base_lower = normalized_base.lower() + if sanitized_lower.startswith(base_lower + "/"): + base_dir = "" + elif sanitized_lower == base_lower: + base_dir = "" base = base_dir.strip("/") combined = posixpath.join(base, sanitized) if base else sanitized normalized = posixpath.normpath(combined)