Skip to content
This repository has been archived by the owner on Jun 5, 2021. It is now read-only.

Commit

Permalink
uri: ignore port error
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed Jan 2, 2020
1 parent 84e5334 commit 61325ce
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,16 @@ 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,
Host: host,
}
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
}
Expand Down

0 comments on commit 61325ce

Please sign in to comment.