Functions§
- base_
domain_ from_ any - base_
domain_ from_ host - Get the base “site” domain from a host.
- base_
domain_ from_ url - ends_
with_ ignore_ ascii_ case - first_
label - host_
and_ rest - Returns (host_without_port, rest_starting_at_/ ? # or empty) Robust: handles protocol-relative, userinfo, IPv6 literals, ports.
- host_
contains_ label_ icase - host_
is_ subdomain_ of - Host matches base if host == base OR host ends with “.{base}” (case-insensitive), with a required dot boundary to prevent “evil-mainr.com” matching “mainr.com”.
- rel_
for_ ignore_ script - Given a base domain (already computed) and a URL, returns the “relative” path for same-site/subdomain URLs, otherwise returns the original URL.