surawut-jirasaktavee commented on code in PR #74452:
URL: https://github.com/apache/airflow/pull/74452#discussion_r4631310078
##########
providers/http/src/airflow/providers/http/hooks/http.py:
##########
@@ -54,10 +54,14 @@
def _url_from_endpoint(base_url: str | None, endpoint: str | None) -> str:
Review Comment:
Good call on making it easier to read. One catch with `strip("/")`:
`"https://".strip("/")` gives `"https:"`, so a scheme-only base URL comes out
as `https:/example.org/v1/test`. That's the case the scheme-only test covers,
and it's what held up #71665. It would also drop a trailing slash from the
endpoint (`/v1/items/` → `v1/items`), and some APIs care about that.
How about this? It's just as short and keeps both cases:
```python
if not base_url or not endpoint:
return (base_url or "") + (endpoint or "")
separator = "" if base_url.endswith("/") else "/"
return base_url + separator + endpoint.lstrip("/")
```
If that works for you, I'll push it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]