From bbee2ee8db3a8178dde04ae5e4d02320fe160ed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Zamanillo?= Date: Tue, 13 Dec 2022 09:07:52 +0100 Subject: [PATCH] Removed else branch typeHostWithOptionalPort return the host raw input value if has not port --- v2/pkg/input/input.go | 9 +++++++-- v2/pkg/input/input_test.go | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) 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", ""},