From 1590e53d8b746a195bbd7ecd0641a41ea5561b75 Mon Sep 17 00:00:00 2001 From: "Jeremie J. Jarosh" Date: Sat, 15 Apr 2023 17:58:24 -0500 Subject: [PATCH] Clean the path the same way on all platforms --- itchiodl/utils.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/itchiodl/utils.py b/itchiodl/utils.py index b5ee124..a5c6f31 100644 --- a/itchiodl/utils.py +++ b/itchiodl/utils.py @@ -1,5 +1,4 @@ import re -import sys import hashlib import requests @@ -38,14 +37,12 @@ def download(url, path, name, file): def clean_path(path): - """Cleans a path on windows""" - if sys.platform in ["win32", "cygwin", "msys"]: - path_clean = re.sub(r"[<>:|?*\"\/\\]", "-", path) - # This checks for strings that end in ... or similar, - # weird corner case that affects fewer than 0.1% of titles - path_clean = re.sub(r"(.)[.]\1+$", "-", path_clean) - return path_clean - return path + """Cleans up invalid filename characters""" + path_clean = re.sub(r"[<>:|?*\"\/\\]", "-", path) + # This checks for strings that end in ... or similar, + # weird corner case that affects fewer than 0.1% of titles + path_clean = re.sub(r"(.)[.]\1+$", "-", path_clean) + return path_clean def md5sum(path):