Skip to content

Commit 738c187

Browse files
committed
Further streamlined 'secure_path' logic
1 parent 329c0d6 commit 738c187

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/murfey/util/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,9 @@ def secure_path(in_path: Path, keep_spaces: bool = False) -> Path:
3131
for p, part in enumerate(in_path.parts):
3232
if p == 0 and ":" in part:
3333
secured_parts.append(secure_filename(part) + ":")
34-
continue # Skip subsequent conditions and move to next part
35-
if keep_spaces:
36-
if " " in part:
37-
secured_parts.append(part)
38-
continue # Skip subsequent conditions and move to next part
39-
if part.endswith("_"):
34+
elif " " in part and keep_spaces:
35+
secured_parts.append(part)
36+
elif part.endswith("_"):
4037
# Preserve all trailing underscores
4138
num_underscores = len(part) - len(part.rstrip("_"))
4239
secured_parts.append(secure_filename(part) + (num_underscores * "_"))

0 commit comments

Comments
 (0)