Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
Signed-off-by: Cabinfever_B <[email protected]>
  • Loading branch information
CabinfeverB committed Mar 12, 2024
1 parent 7429fbd commit f3888ca
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions client/pd_service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -1133,14 +1133,18 @@ func addrsToURLs(addrs []string, tlsCfg *tls.Config) []string {

func addrToURL(addr string, tlsCfg *tls.Config) string {
if tlsCfg == nil {
if strings.HasPrefix(addr, httpsSchemePrefix) {
addr = fmt.Sprintf("%s%s", httpSchemePrefix, strings.TrimPrefix(addr, httpsSchemePrefix))
u, err := url.Parse(addr)
if err == nil {
u.Scheme = httpScheme
addr = u.String()
} else if !strings.HasPrefix(addr, httpSchemePrefix) {
addr = fmt.Sprintf("%s%s", httpSchemePrefix, addr)
}
} else {
if strings.HasPrefix(addr, httpSchemePrefix) {
addr = fmt.Sprintf("%s%s", httpsSchemePrefix, strings.TrimPrefix(addr, httpSchemePrefix))
u, err := url.Parse(addr)
if err == nil {
u.Scheme = httpsScheme
addr = u.String()
} else if !strings.HasPrefix(addr, httpsSchemePrefix) {
addr = fmt.Sprintf("%s%s", httpsSchemePrefix, addr)
}
Expand Down

0 comments on commit f3888ca

Please sign in to comment.