Skip to content

Commit

Permalink
FIX: allow redirects in URL check (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer authored Dec 5, 2023
1 parent 819b016 commit f731cbe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/sphinx_api_relink/linkcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,11 @@ def _get_latest_tag() -> str | None:
@lru_cache(maxsize=None)
def _url_exists(url: str) -> bool:
try:
response = requests.head(url) # noqa: S113
return response.status_code < 300 # noqa: PLR2004, TRY300
response = requests.head(url, timeout=5)
redirect_url = response.headers.get("Location")
if redirect_url is None:
return response.status_code < 400 # noqa: PLR2004
return _url_exists(redirect_url)
except requests.RequestException:
return False

Expand Down

0 comments on commit f731cbe

Please sign in to comment.