export function mergeUrl(...parts) {
  // 将所有部分连接起来，并用斜杠分隔
  let url = parts.join("/");
  let extractedURL = "";
  const regex = /(https?:\/\/)/;
  const match = url.match(regex);
  if (match) {
    extractedURL = match[0];
    url = url.replace(extractedURL, "");
  }
  // 使用正则表达式将连续多个斜杠替换为单个斜杠
  url = url.replace(/\/{2,}/g, "/");

  url = extractedURL + url;
  // 如果是相对路径，则添加当前协议的 host
  if (!/^(\/|https?:\/\/)/i.test(url)) {
    const currentUrl = window.location.href;
    const currentProtocol = currentUrl.split(":")[0];
    const currentHost = currentUrl.split("/").slice(0, 3).join("/");
    url = `${currentProtocol}//${currentHost}/${url}`;
  }
  return url;
}
