Skip to content

Commit

Permalink
[DISCO-2866]: replace current conditions and forecast url scheme to h…
Browse files Browse the repository at this point in the history
…ttps (#542)

* patch: replace current conditions and forecast url scheme to https

* fix lint
  • Loading branch information
Herraj authored Jun 24, 2024
1 parent b885ffd commit a13775c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 48 deletions.
8 changes: 5 additions & 3 deletions merino/providers/weather/backends/accuweather.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,11 +761,14 @@ def add_partner_code(
url: str, url_param_id: str | None = None, partner_code: str | None = None
) -> str:
"""Add the partner code to the given URL."""
# reformat the http url returned for current conditions and forecast to https
https_url = url if url.startswith("https:") else url.replace("http:", "https:", 1)

if not url_param_id or not partner_code:
return url
return https_url

try:
parsed_url = URL(url)
parsed_url = URL(https_url)
return str(parsed_url.copy_add_param(url_param_id, partner_code))
except InvalidURL: # pragma: no cover
return url
Expand Down Expand Up @@ -841,7 +844,6 @@ def process_current_condition_response(response: Any) -> dict[str, Any] | None:
# lines as unreachable. See
# https://github.com/python/mypy/issues/12770
url = add_partner_code(url, PARTNER_PARAM_ID, PARTNER_CODE) # type: ignore

return {
"url": url,
"summary": summary,
Expand Down
Loading

0 comments on commit a13775c

Please sign in to comment.