You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by di...@apache.org on 2020/11/02 07:46:46 UTC

[rocketmq-client-go] branch master updated: [#540] Fix parse address error when address has prefix "t"

This is an automated email from the ASF dual-hosted git repository.

dinglei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-go.git


The following commit(s) were added to refs/heads/master by this push:
     new e1d9be8  [#540] Fix parse address error when address has prefix "t"
e1d9be8 is described below

commit e1d9be806c182c142aee212eab27e413705f4e79
Author: 赵鹏飞 <12...@qq.com>
AuthorDate: Mon Nov 2 15:46:36 2020 +0800

    [#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 <ju...@alibaba-inc.com>
---
 internal/namesrv.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/internal/namesrv.go b/internal/namesrv.go
index 371b431..a47bbc1 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 {