Companion helper for the url_standard selector: reports the host
type of each URL as exactly one of "domain", "ipv4",
"ipv6", "reg-name", or "missing". Unlike a raw host
string, host_type is a function of both the host and the
selected standard: the numeric host 2130706433 is a "reg-name"
under "rfc3986" but an "ipv4" address under "whatwg".
Callers reading the result must therefore know which selector produced it.
Arguments
- url
A character vector of URLs.
- url_standard
Standard profile governing host interpretation:
NULL(default; no classification, returnsNA),"rfc3986", or"whatwg". The gate is semantic, not stylistic: whether a host is an IPv4 literal or a registered name is a question only a standard answers, so with no selector there is no fact to report.get_parse_verdictsis deliberately not gated this way — its layers describe the parse that actually ran, which is defined with or without a selector.- scheme_policy
Controls whether scheme-less, host-shaped input is accepted (an input-acceptance axis, distinct from
protocol_handling, which only controls how the scheme is presented, and fromurl_standard, which controls interpretation). Defaults to "infer"."infer": (Default) Fabricate
http://for scheme-less host-shaped input (e.g.example.comparses ashttp://example.com), a browser-omnibox-style affordance. This is the historical behavior."require": Reject scheme-less input — a scheme-less host-shaped value becomes
parse_status = "error"rather than gaining a fabricated scheme. Use this for a strict, pure-parser posture. Note this governs only bare host input; scheme-relative//hostinput is governed separately byscheme_relative_handling.
- scheme_acceptance
Which scheme tokens may enter parsing (a scheme-acceptance axis, distinct from
scheme_policy, which governs scheme-less input, and fromurl_standard, which governs interpretation). Defaults to "web"."web": (Default) Only the curated web-scheme allowlist (
http/https/ftp/ftps/file) is admitted; a scheme-bearing input outside it isparse_status = "error". This is the historical, byte-for-byte compatible behavior."general": Admit any syntactically valid scheme token and parse opaque (
mailto:x), non-special (foo://host), and RFC-generic URLs. Requires an expliciturl_standard("rfc3986"or"whatwg"), which decides the interpretation;generalwithurl_standard = NULLis an error. Non-special / opaque hosts receive no www-stripping, no domain/TLD derivation, and are never run through the IDNA/punycode helpers. A non-special scheme with no//is an opaque path: it has no authority, sohost,user,portand thedomain/tldcolumns are allNAand the entire remainder is thepath(query/fragmentare still split off). This includesmailto:— the recipient's@never re-triggers authority parsing. To decompose amailto:recipient, use the accessors (get_host()/get_domain()/get_user(), ADR 0012 D7) orget_mailto_recipients(); those deliberately return a recipient's parts where this table presentsNA, because a recipient domain is extraction metadata, not the URL's authority.
Value
A character vector the same length as url, each element one of
the host_type tokens above, or NA when no selector is given.
Details
The metadata is intentionally exposed through this helper rather than as a
column on safe_parse_urls or a field on
safe_parse_url, so that passing no selector leaves every
existing function's output shape unchanged.