Skip to content

Commit

Permalink
[#540] Fix parse address error when address has prefix "t"
Browse files Browse the repository at this point in the history
in same cases, such as addr="http://tim.test.com:9876", then
strings.TrimLeft(addr, "http(s)://") will get "im.test.com:9876" instead
of "tim.test.com:9876"

Signed-off-by: pengfei <[email protected]>
  • Loading branch information
1216114309zpf authored Nov 2, 2020
1 parent 2a65561 commit e1d9be8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/namesrv.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ func (s *namesrvs) getNameServerAddress() string {
}
index %= len(s.srvs)
s.index = index
return strings.TrimLeft(addr, "http(s)://")
if strings.HasPrefix(addr, "https") {
return strings.TrimPrefix(addr, "https://")
}
return strings.TrimPrefix(addr, "http://")
}

func (s *namesrvs) Size() int {
Expand Down

0 comments on commit e1d9be8

Please sign in to comment.