From a011d560c64ec935b47faed4cca9df59e043f9c3 Mon Sep 17 00:00:00 2001 From: starry <115192496+sky22333@users.noreply.github.com> Date: Thu, 4 Sep 2025 04:13:21 +0800 Subject: [PATCH] =?UTF-8?q?shell=E8=BD=AC=E6=8D=A2=E4=B8=AD=E7=A1=AE?= =?UTF-8?q?=E4=BF=9Dhost=E6=9C=89=E5=8D=8F=E8=AE=AE=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/proxy_shell.go | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/utils/proxy_shell.go b/src/utils/proxy_shell.go index d83313f..12af000 100644 --- a/src/utils/proxy_shell.go +++ b/src/utils/proxy_shell.go @@ -77,18 +77,21 @@ func processGitHubURLs(content, host string) string { // transformURL URL转换函数 func transformURL(url, host string) string { - if strings.Contains(url, host) { - return url - } + if strings.Contains(url, host) { + return url + } - if strings.HasPrefix(url, "http://") { - url = "https" + url[4:] - } else if !strings.HasPrefix(url, "https://") && !strings.HasPrefix(url, "//") { - url = "https://" + url - } - cleanHost := strings.TrimPrefix(host, "https://") - cleanHost = strings.TrimPrefix(cleanHost, "http://") - cleanHost = strings.TrimSuffix(cleanHost, "/") + if strings.HasPrefix(url, "http://") { + url = "https" + url[4:] + } else if !strings.HasPrefix(url, "https://") && !strings.HasPrefix(url, "//") { + url = "https://" + url + } - return cleanHost + "/" + url + // 确保 host 有协议头 + if !strings.HasPrefix(host, "http://") && !strings.HasPrefix(host, "https://") { + host = "https://" + host + } + host = strings.TrimSuffix(host, "/") + + return host + "/" + url }