From e1d9be806c182c142aee212eab27e413705f4e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=B9=8F=E9=A3=9E?= <1216114309@qq.com> Date: Mon, 2 Nov 2020 15:46:36 +0800 Subject: [PATCH] [#540] Fix parse address error when address has prefix "t" 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 --- internal/namesrv.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/namesrv.go b/internal/namesrv.go index 371b4318..a47bbc15 100644 --- a/internal/namesrv.go +++ b/internal/namesrv.go @@ -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 {