Removed else branch

typeHostWithOptionalPort return the host raw input value if has not port
This commit is contained in:
Víctor Zamanillo 2022-12-13 09:07:52 +01:00
parent c97c3aca33
commit bbee2ee8db
2 changed files with 8 additions and 3 deletions

View File

@ -100,9 +100,8 @@ func (h *Helper) convertInputToType(input string, inputType inputType, defaultPo
}
if isURL {
return uri.Hostname()
} else {
return input
}
return input
case typeURL:
if uri != nil && (uri.Scheme == "http" || uri.Scheme == "https") {
return input
@ -122,6 +121,12 @@ func (h *Helper) convertInputToType(input string, inputType inputType, defaultPo
if hasDefaultPort {
return net.JoinHostPort(input, defaultPort)
}
if inputType == typeHostWithOptionalPort {
return input
}
return ""
case typeWebsocket:
if uri != nil && (uri.Scheme == "ws" || uri.Scheme == "wss") {
return input

View File

@ -51,7 +51,7 @@ func TestConvertInputToType(t *testing.T) {
{"google.com", typeHostWithPort, "google.com:443", "443"},
// host with optional port
{"google.com", typeHostWithOptionalPort, "", ""},
{"google.com", typeHostWithOptionalPort, "google.com", ""},
{"google.com:443", typeHostWithOptionalPort, "google.com:443", ""},
{"https://google.com", typeHostWithOptionalPort, "google.com:443", ""},
{"https://google.com:443", typeHostWithOptionalPort, "google.com:443", ""},