Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .flocks/plugins/tools/device/tdp_v3_3_10/tdp.handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ def _resolve_ref(value: Any) -> str | None:
return value


def _normalize_base_url(base_url: str) -> str:
"""Return the TDP service origin, not a UI/API page path."""
normalized = base_url.strip().rstrip("/")
for suffix in ("/config/api", "/api/v1"):
if normalized.lower().endswith(suffix):
normalized = normalized[: -len(suffix)].rstrip("/")
break
return normalized


def _service_config() -> dict[str, Any]:
raw = ConfigWriter.get_api_service_raw(SERVICE_ID)
return raw if isinstance(raw, dict) else {}
Expand Down Expand Up @@ -136,7 +146,7 @@ def _resolve_runtime_config() -> RuntimeConfig:
or DEFAULT_BASE_URL
)
if base_url:
base_url = base_url.strip().rstrip("/")
base_url = _normalize_base_url(base_url)
if not base_url.startswith(("http://", "https://")):
base_url = f"https://{base_url}"

Expand Down
Loading