diff --git a/v2/pkg/input/input.go b/v2/pkg/input/input.go index 14029f940..abbebc73a 100644 --- a/v2/pkg/input/input.go +++ b/v2/pkg/input/input.go @@ -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 diff --git a/v2/pkg/input/input_test.go b/v2/pkg/input/input_test.go index a4ae6bfbd..76cabd3b5 100644 --- a/v2/pkg/input/input_test.go +++ b/v2/pkg/input/input_test.go @@ -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", ""},