Skip to content

Commit

Permalink
url多个问题 (#1306)
Browse files Browse the repository at this point in the history
Co-authored-by: wangxiaowei14227 <wangxiaowei14227@autohome.com.cn>
  • Loading branch information
XiaoWeiKIN and wangxiaowei14227 committed Jul 8, 2021
1 parent 21e9f4e commit 2e8402e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions common/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,13 @@ func NewURL(urlString string, opts ...Option) (*URL, error) {
s.Password, _ = serviceURL.User.Password()
s.Location = serviceURL.Host
s.Path = serviceURL.Path
if strings.Contains(s.Location, ":") {
s.Ip, s.Port, err = net.SplitHostPort(s.Location)
if err != nil {
return &s, perrors.Errorf("net.SplitHostPort(URL.Host{%s}), error{%v}", s.Location, err)
for _, location := range strings.Split(s.Location, ",") {
if strings.Contains(location, ":") {
s.Ip, s.Port, err = net.SplitHostPort(location)
if err != nil {
return &s, perrors.Errorf("net.SplitHostPort(url.Host{%s}), error{%v}", s.Location, err)
}
break
}
}
for _, opt := range opts {
Expand Down

0 comments on commit 2e8402e

Please sign in to comment.