From 61325ce9395a8281d51e833667428d395c01b271 Mon Sep 17 00:00:00 2001 From: Aleksandr Razumov Date: Fri, 3 Jan 2020 00:51:27 +0300 Subject: [PATCH] uri: ignore port error --- uri.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/uri.go b/uri.go index e26fe53..781c2cb 100644 --- a/uri.go +++ b/uri.go @@ -44,8 +44,6 @@ func ParseURI(rawURI string) (URI, error) { } // Using URL methods to split host. u.Host = u.Opaque - // TODO: validate host and port. - // See https://github.com/golang/go/issues/29098. host, rawPort := u.Hostname(), u.Port() uri := URI{ Scheme: u.Scheme, @@ -53,8 +51,9 @@ func ParseURI(rawURI string) (URI, error) { } if len(rawPort) > 0 { port, portErr := strconv.Atoi(rawPort) - if portErr != nil { - return uri, fmt.Errorf("failed to parse %q as port: %v", rawPort, portErr) + if portErr == nil { + // URL parser already verifies that port is integer. + uri.Port = port } uri.Port = port }