Reference¶
Check the safety of a redirect URL.
Extracted from Django's url_has_allowed_host_and_scheme
.
url_has_allowed_host_and_scheme(url, allowed_hosts=None, require_https=False)
¶
Return True
if the url uses an allowed host and a safe scheme.
Always return False
on an empty url.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
The URL to test. |
required |
allowed_hosts |
str | set[str] | None
|
Set of allowed hosts. |
None
|
require_https |
bool
|
If |
False
|