MCPcopy
hub / github.com/django/django / split_domain_port

Function split_domain_port

django/http/request.py:843–854  ·  view source on GitHub ↗

Return a (domain, port) tuple from a given host. Returned domain is lowercased. If the host is invalid, the domain will be empty.

(host)

Source from the content-addressed store, hash-verified

841
842
843def split_domain_port(host):
844 """
845 Return a (domain, port) tuple from a given host.
846
847 Returned domain is lowercased. If the host is invalid, the domain will be
848 empty.
849 """
850 if match := host_validation_re.fullmatch(host.lower()):
851 domain, port = match.groups(default="")
852 # Remove a trailing dot (if present) from the domain.
853 return domain.removesuffix("."), port
854 return "", ""
855
856
857def validate_host(host, allowed_hosts):

Callers 4

_get_site_by_requestMethod · 0.90
assertRedirectsMethod · 0.90
get_hostMethod · 0.85

Calls 1

groupsMethod · 0.80

Tested by 2

assertRedirectsMethod · 0.72