diff --git a/faker/providers/file/__init__.py b/faker/providers/file/__init__.py index 5c61b38a77..f84fa13d2b 100644 --- a/faker/providers/file/__init__.py +++ b/faker/providers/file/__init__.py @@ -291,7 +291,7 @@ def file_path( file: str = self.file_name(category, extension) if no_extension: - file = re.sub(r"\.[^/]+$", "", file) + file = file.rsplit(".", 1)[0] path: str = f"/{file}" for _ in range(0, depth): path = f"/{self.generator.word()}{path}"