mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-10-22 01:22:34 +00:00
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>
19 lines
500 B
Python
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)
|