From 67a190c3d79b74402a66c6a582b9810c2dc1e855 Mon Sep 17 00:00:00 2001 From: Vinicius Fortuna Date: Tue, 29 Oct 2024 00:17:37 -0400 Subject: [PATCH] Fix test --- x/configurl/config.go | 15 +++++++++------ x/configurl/shadowsocks_test.go | 5 ++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/x/configurl/config.go b/x/configurl/config.go index 628bbe67..7e7aaa94 100644 --- a/x/configurl/config.go +++ b/x/configurl/config.go @@ -273,11 +273,10 @@ func SanitizeConfig(configStr string) (string, error) { return "", nil } - // Iterate through each part - textParts := make([]string, 0, 1) + var sanitized string for config != nil { - scheme := strings.ToLower(config.URL.Scheme) var part string + scheme := strings.ToLower(config.URL.Scheme) switch scheme { case "ss": part, err = sanitizeShadowsocksURL(config.URL) @@ -295,10 +294,14 @@ func SanitizeConfig(configStr string) (string, error) { default: part = scheme + "://UNKNOWN" } - textParts = append(textParts, part) + if sanitized == "" { + sanitized = part + } else { + sanitized = part + "|" + sanitized + } + config = config.BaseConfig } - // Join the parts back into a string - return strings.Join(textParts, "|"), nil + return sanitized, nil } func sanitizeSocks5URL(u *url.URL) (string, error) { diff --git a/x/configurl/shadowsocks_test.go b/x/configurl/shadowsocks_test.go index ae394e0b..e24245c5 100644 --- a/x/configurl/shadowsocks_test.go +++ b/x/configurl/shadowsocks_test.go @@ -142,7 +142,6 @@ func TestParseShadowsocksSIP002URLUnsuccessful(t *testing.T) { require.NoError(t, err) require.Nil(t, config.BaseConfig) - _, err = parseShadowsocksURL(config.URL) - - require.Error(t, err) + _, err = parseShadowsocksSIP002URL(config.URL) + require.Error(t, err, "URL is %v", config.URL.String()) }