diff --git a/airflow-ctl/src/airflowctl/api/client.py b/airflow-ctl/src/airflowctl/api/client.py index 5a719cac164cc..579d78ef0aa23 100644 --- a/airflow-ctl/src/airflowctl/api/client.py +++ b/airflow-ctl/src/airflowctl/api/client.py @@ -226,6 +226,7 @@ def _get_base_url( cls, base_url: str, kind: Literal[ClientKind.AUTH, ClientKind.CLI] = ClientKind.CLI ) -> str: """Get the base URL of the client.""" + base_url = base_url.rstrip("/") if kind == ClientKind.AUTH: return f"{base_url}/auth" return f"{base_url}/api/v2" diff --git a/airflow-ctl/tests/airflow_ctl/api/test_client.py b/airflow-ctl/tests/airflow_ctl/api/test_client.py index 39ffc436706c9..5913009ecd411 100644 --- a/airflow-ctl/tests/airflow_ctl/api/test_client.py +++ b/airflow-ctl/tests/airflow_ctl/api/test_client.py @@ -93,6 +93,10 @@ def handle_request(request: httpx.Request) -> httpx.Response: ("http://localhost:8080", ClientKind.AUTH, "http://localhost:8080/auth/"), ("https://example.com", ClientKind.CLI, "https://example.com/api/v2/"), ("https://example.com", ClientKind.AUTH, "https://example.com/auth/"), + ("http://localhost:8080/", ClientKind.CLI, "http://localhost:8080/api/v2/"), + ("http://localhost:8080/", ClientKind.AUTH, "http://localhost:8080/auth/"), + ("https://example.com/", ClientKind.CLI, "https://example.com/api/v2/"), + ("https://example.com/", ClientKind.AUTH, "https://example.com/auth/"), ], ) def test_refresh_base_url(self, base_url, client_kind, expected_base_url):