From d4f000466f34766d28c754c824637eb1a3d67b79 Mon Sep 17 00:00:00 2001
From: pb <pierre.bayle@irt-saintexupery.com>
Date: Wed, 5 Mar 2025 12:18:07 +0100
Subject: [PATCH] add print for url

---
 models/peer/peer_cache.go | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/models/peer/peer_cache.go b/models/peer/peer_cache.go
index a6cf142..62ffbac 100644
--- a/models/peer/peer_cache.go
+++ b/models/peer/peer_cache.go
@@ -29,28 +29,29 @@ type PeerCache struct {
 }
 
 // urlFormat formats the URL of the peer with the data type API function
-func (p *PeerCache) urlFormat(url string, dt tools.DataType) string {
+func (p *PeerCache) urlFormat(hostUrl string, dt tools.DataType) string {
 	// localhost is replaced by the local peer URL
 	// because localhost must collide on a web request security protocol
 	localhost := ""
-	if strings.Contains(url, "localhost") {
+	if strings.Contains(hostUrl, "localhost") {
 		localhost = "localhost"
 	}
-	if strings.Contains(url, "127.0.0.1") {
+	if strings.Contains(hostUrl, "127.0.0.1") {
 		localhost = "127.0.0.1"
 	}
 	if localhost != "" {
 		r := regexp.MustCompile("(" + localhost + ":[0-9]+)")
-		t := r.FindString(url)
+		t := r.FindString(hostUrl)
 		if t != "" {
-			url = strings.Replace(url, t, dt.API()+":8080/oc", -1)
+			hostUrl = strings.Replace(hostUrl, t, dt.API()+":8080/oc", -1)
 		} else {
-			url = strings.ReplaceAll(url, localhost, dt.API()+":8080/oc")
+			hostUrl = strings.ReplaceAll(hostUrl, localhost, dt.API()+":8080/oc")
 		}
 	} else {
-		url = dt.API() + "/" + url
+		hostUrl = dt.API() + "/" + hostUrl
 	}
-	return url
+	fmt.Println("HostURL : ", hostUrl)
+	return hostUrl
 }
 
 // checkPeerStatus checks the status of a peer