shell转换中确保host有协议头

This commit is contained in:
starry
2025-09-04 04:13:21 +08:00
committed by GitHub
parent 53060d50db
commit a011d560c6

View File

@@ -86,9 +86,12 @@ func transformURL(url, host string) string {
} else if !strings.HasPrefix(url, "https://") && !strings.HasPrefix(url, "//") { } else if !strings.HasPrefix(url, "https://") && !strings.HasPrefix(url, "//") {
url = "https://" + url url = "https://" + url
} }
cleanHost := strings.TrimPrefix(host, "https://")
cleanHost = strings.TrimPrefix(cleanHost, "http://")
cleanHost = strings.TrimSuffix(cleanHost, "/")
return cleanHost + "/" + url // 确保 host 有协议头
if !strings.HasPrefix(host, "http://") && !strings.HasPrefix(host, "https://") {
host = "https://" + host
}
host = strings.TrimSuffix(host, "/")
return host + "/" + url
} }