Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
张洁俊(Jack) committed Jan 19, 2024
1 parent b06ce74 commit e909617
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion opensearchtransport/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func (c *Client) getNodeURL(node nodeInfo, scheme string) *url.URL {
var (
host string
port string
err error

addrs = strings.Split(node.HTTP.PublishAddress, "/")
ports = strings.Split(node.HTTP.PublishAddress, ":")
Expand All @@ -188,7 +189,10 @@ func (c *Client) getNodeURL(node nodeInfo, scheme string) *url.URL {
if len(addrs) > 1 {
host = addrs[0]
} else {
host, _, _ = net.SplitHostPort(addrs[0])
host, port, err = net.SplitHostPort(addrs[0])
if err != nil {
host = strings.Split(addrs[0], ":")[0]
}
}

port = ports[len(ports)-1]
Expand Down

0 comments on commit e909617

Please sign in to comment.