From 4d1d1f8b5496121a8031f4b589416ba6deaea79f Mon Sep 17 00:00:00 2001 From: edouardbruelhart Date: Tue, 20 Aug 2024 09:34:10 +0200 Subject: [PATCH 1/5] corrected issue 605 --- qfieldsync/core/cloud_api.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qfieldsync/core/cloud_api.py b/qfieldsync/core/cloud_api.py index 05040fc6..911c5923 100644 --- a/qfieldsync/core/cloud_api.py +++ b/qfieldsync/core/cloud_api.py @@ -226,9 +226,14 @@ def set_url(self, server_url: str) -> None: if not server_url: server_url = CloudNetworkAccessManager.server_urls()[0] - # Ignore the URL path, as we assume the url is always /api/v1. Assume the URL has a scheme or at least starts with leading //. + # Ignore the URL path in certain conditions. Assume the URL has a scheme or at least starts with leading //. p = urlparse(server_url) - self.url = f"{p.scheme or 'https'}://{p.netloc}/" + + if p.path.startswith("/api") or p.path == "/": + self.url = f"{p.scheme or 'https'}://{p.netloc}/" + else: + self.url = f"{p.scheme or 'https'}://{p.netloc}{p.path}" + self.preferences.set_value("qfieldCloudServerUrl", server_url) @property From a2358798a807d64184755c8834dce3fa8ba3831c Mon Sep 17 00:00:00 2001 From: edouardbruelhart Date: Mon, 18 Nov 2024 09:00:53 +0100 Subject: [PATCH 2/5] Update qfieldsync/core/cloud_api.py Correction by suricactus Co-authored-by: Ivan Ivanov --- qfieldsync/core/cloud_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfieldsync/core/cloud_api.py b/qfieldsync/core/cloud_api.py index 911c5923..ecdc4a89 100644 --- a/qfieldsync/core/cloud_api.py +++ b/qfieldsync/core/cloud_api.py @@ -226,7 +226,7 @@ def set_url(self, server_url: str) -> None: if not server_url: server_url = CloudNetworkAccessManager.server_urls()[0] - # Ignore the URL path in certain conditions. Assume the URL has a scheme or at least starts with leading //. + # Assume the URL has a scheme or at least starts with leading //. p = urlparse(server_url) if p.path.startswith("/api") or p.path == "/": From b834e5035c4142f415330f4b2a5ddae778350a9d Mon Sep 17 00:00:00 2001 From: edouardbruelhart Date: Mon, 18 Nov 2024 09:02:00 +0100 Subject: [PATCH 3/5] Update qfieldsync/core/cloud_api.py corrected by suricactus Co-authored-by: Ivan Ivanov --- qfieldsync/core/cloud_api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qfieldsync/core/cloud_api.py b/qfieldsync/core/cloud_api.py index ecdc4a89..03567bd9 100644 --- a/qfieldsync/core/cloud_api.py +++ b/qfieldsync/core/cloud_api.py @@ -229,7 +229,8 @@ def set_url(self, server_url: str) -> None: # Assume the URL has a scheme or at least starts with leading //. p = urlparse(server_url) - if p.path.startswith("/api") or p.path == "/": + // QFieldSync will automatically append `/api/v1` to the path, so prevent double append like `/api/v1/api/v1`. + if p.path.startswith("/api/v1"): self.url = f"{p.scheme or 'https'}://{p.netloc}/" else: self.url = f"{p.scheme or 'https'}://{p.netloc}{p.path}" From 49e47d3682a541f4584ed42b00f2fc33dc5f6da0 Mon Sep 17 00:00:00 2001 From: edouardbruelhart Date: Mon, 18 Nov 2024 09:03:17 +0100 Subject: [PATCH 4/5] pre-commit run --- qfieldsync/core/cloud_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfieldsync/core/cloud_api.py b/qfieldsync/core/cloud_api.py index 911c5923..d23b6299 100644 --- a/qfieldsync/core/cloud_api.py +++ b/qfieldsync/core/cloud_api.py @@ -233,7 +233,7 @@ def set_url(self, server_url: str) -> None: self.url = f"{p.scheme or 'https'}://{p.netloc}/" else: self.url = f"{p.scheme or 'https'}://{p.netloc}{p.path}" - + self.preferences.set_value("qfieldCloudServerUrl", server_url) @property From dadeab5749a37b8e58aba22b58119a6f980ed7ad Mon Sep 17 00:00:00 2001 From: edouardbruelhart Date: Mon, 18 Nov 2024 09:13:19 +0100 Subject: [PATCH 5/5] Use # instead of // for comment --- qfieldsync/core/cloud_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfieldsync/core/cloud_api.py b/qfieldsync/core/cloud_api.py index 25b80295..8bb0d2e3 100644 --- a/qfieldsync/core/cloud_api.py +++ b/qfieldsync/core/cloud_api.py @@ -229,7 +229,7 @@ def set_url(self, server_url: str) -> None: # Assume the URL has a scheme or at least starts with leading //. p = urlparse(server_url) - // QFieldSync will automatically append `/api/v1` to the path, so prevent double append like `/api/v1/api/v1`. + # QFieldSync will automatically append `/api/v1` to the path, so prevent double append like `/api/v1/api/v1`. if p.path.startswith("/api/v1"): self.url = f"{p.scheme or 'https'}://{p.netloc}/" else: