Refactor URL creation to use reusable join_url utility
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -32,3 +32,16 @@ def is_private_ip(hostname: str) -> bool:
|
||||
# Log this for debugging
|
||||
logger.warning(f"Could not resolve hostname: {hostname}")
|
||||
return False # Changed from True to False to allow external domains in tests
|
||||
|
||||
|
||||
def join_url(base: str, *parts: str) -> str:
|
||||
"""
|
||||
Safely join a base URL and multiple path parts.
|
||||
Handles double slashes while preserving the protocol '://'.
|
||||
"""
|
||||
url = "/".join([base, *parts])
|
||||
url = url.replace("://", "$PLACEHOLDER$")
|
||||
while "//" in url:
|
||||
url = url.replace("//", "/")
|
||||
url = url.replace("$PLACEHOLDER$", "://")
|
||||
return url
|
||||
|
||||
Reference in New Issue
Block a user