diff --git a/models/peer/peer_cache.go b/models/peer/peer_cache.go index 82b9f1b..6ae2440 100644 --- a/models/peer/peer_cache.go +++ b/models/peer/peer_cache.go @@ -56,8 +56,8 @@ func (p *PeerCache) checkPeerStatus(peerID string, caller *tools.HTTPCaller) boo url = strings.ReplaceAll(url, "localhost", utils.PEER.API()) url = strings.ReplaceAll(url, "127.0.0.1", utils.PEER.API()) r := regexp.MustCompile("(:[0-9]+)") - ttt := r.FindAllString(url, -1) - for _, t := range ttt { + t := r.FindString(url) + if t != "" { url = strings.Replace(url, t, ":8080", -1) } r.ReplaceAllString(url, ":8080") @@ -82,8 +82,8 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, isMySelf bool, dataID str url = strings.ReplaceAll(url, "localhost", dt.API()) url = strings.ReplaceAll(url, "127.0.0.1", dt.API()) r := regexp.MustCompile("(:[0-9]+)") - ttt := r.FindAllString(url, -1) - for _, t := range ttt { + t := r.FindString(url) + if t != "" { url = strings.Replace(url, t, ":8080", -1) } r.ReplaceAllString(url, ":8080")