Uses safe_parse_url internally to extract the TLD, benefiting from all memoization layers for improved performance.
Arguments
- url
A character vector of URLs.
- source
Which TLD source to use: "all", "icann", or "private".
- host_encoding
How to present the host in
clean_url. Defaults to "keep"."keep": Leave host as parsed by curl (may preserve original case).
"idna": Convert Unicode host labels to Punycode (IDNA) for the cleaned URL.
"unicode": Decode Punycode labels to Unicode for the cleaned URL.
- 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.
- url_standard
Optional top-level standard profile:
NULL(default),"rfc3986", or"whatwg". WithNULLthe behavior is exactly what the individual low-level options select (fully backward compatible). When set, it selects a coherent set of standard-conformant behaviors for the axes it governs — path percent/dot handling, the host IPv4/reg-name model, andcase_handling— so callers do not have to hand-assemble the low-level knobs. Passing a governed low-level knob (path_normalizationorcase_handling) with a value the selected profile would not choose is an error; passing the value the profile would pick is accepted (onlycase_handling = "lower_host"is accepted under a selector —"keep","lower", and"upper"all conflict, since"lower"also lowercases the path, which neither standard sanctions). Added as the last argument so existing positional calls keep their meaning; always pass it by name. Under"whatwg"the selector additionally recognizes a literal backslash as a path separator for WHATWG-special schemes (http/https/ftp) and nulls default ports in parse output; useport_handling = "strip_default"for spec-style clean URL port rendering. Seeresolve_urlforurl_standard-governed reference resolution. The selector does not govern whetherport_handlingmay be set (it is a standalone editorial knob), nor does it governpath_encoding(an orthogonal path-presentation knob that layers on any profile), IDNA rendering, or query handling.- engine
Optional pslr engine controlling which Public Suffix List backs domain / TLD / subdomain extraction:
NULL(default) resolves against pslr's session-global default list — exactly the historical behavior — while apslr::psl_engine()snapshot resolves against that specific list, per request, without mutating any global state (never callpslr::psl_use()for this). Use it to pin a particular list version or to load an alternate list viapslr::psl_engine(source = "path", path = ...). Process-local: an engine holds a C++ external pointer that does not serialize across R sessions or parallel workers — build it in the process that uses it; never cache it to disk or send it to a worker (rebuild one per process instead). Only the domain-derived outputs (domain,tld, and the subdomain-trimmed host /clean_url) depend on it.