Files
DB-GPT/dbgpt/core/awel/util/http_util.py
明天 d5afa6e206 Native data AI application framework based on AWEL+AGENT (#1152)
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com>
Co-authored-by: lcx01800250 <lcx01800250@alibaba-inc.com>
Co-authored-by: licunxing <864255598@qq.com>
Co-authored-by: Aralhi <xiaoping0501@gmail.com>
Co-authored-by: xuyuan23 <643854343@qq.com>
Co-authored-by: aries_ckt <916701291@qq.com>
Co-authored-by: hzh97 <2976151305@qq.com>
2024-02-07 17:43:27 +08:00

19 lines
500 B
Python

"""HTTP utilities."""
import re
def join_paths(*paths):
"""Join multiple paths into one path.
Delete the spaces and slashes at both ends of each path, and ensure that there is
only one slash between the paths.
"""
stripped_paths = [
re.sub(r"^[/\s]+|[/\s]+$", "", path) for path in paths if path.strip("/")
]
full_path = "/".join(stripped_paths)
# Replace multiple consecutive slashes with a single slash
return re.sub(r"/{2,}", "/", "/" + full_path)