Skip to content

Commit

Permalink
normalize urls for urlcheck.py
Browse files Browse the repository at this point in the history
Normalize URLs in `check_url_status` before checking for custom 404 redirects
  • Loading branch information
cordt-sei authored Oct 15, 2024
1 parent 18fcbd1 commit 83c7583
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scripts/urlcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
def check_url_status(url):
try:
response = requests.head(url, allow_redirects=True, timeout=5)
final_url = response.url # Get the final URL after redirects
final_url = response.url.rstrip('/')
if final_url == INTERNAL_404_URL.rstrip('/') or "404" in final_url:
return 404, "Redirected to 404", final_url
return response.status_code, response.reason, final_url
except requests.RequestException as e:
return None, str(e), None
Expand Down

0 comments on commit 83c7583

Please sign in to comment.