Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Oct 29, 2024
1 parent d3712d1 commit 67a190c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 9 additions & 6 deletions x/configurl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions x/configurl/shadowsocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

0 comments on commit 67a190c

Please sign in to comment.