diff --git a/pkg/freecad/silo_commands.py b/pkg/freecad/silo_commands.py index 54b8f78..a5e1ca2 100644 --- a/pkg/freecad/silo_commands.py +++ b/pkg/freecad/silo_commands.py @@ -29,9 +29,14 @@ def _get_api_url() -> str: if not url: url = os.environ.get("SILO_API_URL", "http://localhost:8080/api") url = url.rstrip("/") - # Auto-append /api if the user provided just the base hostname - if url and not url.endswith("/api"): - url = url + "/api" + # Auto-append /api when the user provides just a bare origin with no path, + # e.g. "https://silo.kindred.internal" -> "https://silo.kindred.internal/api" + # but leave URLs that already have a path alone, + # e.g. "http://localhost:8080/api" stays as-is. + if url: + parsed = urllib.parse.urlparse(url) + if not parsed.path or parsed.path == "/": + url = url + "/api" return url @@ -1852,7 +1857,7 @@ class Silo_Settings: layout.addWidget(url_label) url_input = QtGui.QLineEdit() - url_input.setPlaceholderText("https://silo.kindred.internal") + url_input.setPlaceholderText("http://localhost:8080/api") current_url = param.GetString("ApiUrl", "") if current_url: url_input.setText(current_url) @@ -1863,9 +1868,9 @@ class Silo_Settings: layout.addWidget(url_input) url_hint = QtGui.QLabel( - "Enter the server hostname (e.g. https://silo.kindred.internal). " - "The /api path is appended automatically. " - "Leave empty to use SILO_API_URL environment variable." + "Full URL with path (e.g. http://localhost:8080/api) or just the " + "hostname (e.g. https://silo.kindred.internal) and /api is " + "appended automatically. Leave empty for SILO_API_URL env var." ) url_hint.setWordWrap(True) url_hint.setStyleSheet("color: #888; font-size: 11px;")