from urllib.parse import quote def encode_path(path: str) -> str: if not path: return "" return "/".join(quote(part, safe="") for part in path.split("/"))