Skip to content

Commit 6b9b57f

Browse files
committed
refactor: reuse normalized host when building request URLs
1 parent 05f345c commit 6b9b57f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

posthog/request.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ def post(
198198
log = logging.getLogger("posthog")
199199
body = kwargs
200200
body["sentAt"] = datetime.now(tz=tzutc()).isoformat()
201-
url = remove_trailing_slash(normalize_host(host)) + path
201+
trimmed_host = remove_trailing_slash(normalize_host(host))
202+
url = trimmed_host + path
202203
body["api_key"] = api_key
203204
data = json.dumps(body, cls=DatetimeSerializer)
204205
log.debug("making request: %s to url: %s", data, url)
@@ -338,7 +339,8 @@ def get(
338339
- not_modified=False and data=response if server returns 200
339340
"""
340341
log = logging.getLogger("posthog")
341-
full_url = remove_trailing_slash(normalize_host(host)) + url
342+
trimmed_host = remove_trailing_slash(normalize_host(host))
343+
full_url = trimmed_host + url
342344
headers = {"Authorization": "Bearer %s" % api_key, "User-Agent": USER_AGENT}
343345

344346
if etag:

0 commit comments

Comments
 (0)