Learn R Programming

rurl (version 3.0.1)

url_profile: Inspect a named parsing profile

Description

Expands a named profile into the resolved bundle of low-level parser knobs it sets, running the exact same resolution the parse functions (safe_parse_url, safe_parse_urls, get_clean_url) apply when you pass profile. It never parses a URL; it answers “what does this profile actually do, and did my explicit overrides change it?”.

Usage

url_profile(profile = NULL, ...)

Value

A named list of the resolved knob \(\rightarrow\) value pairs the profile sets (the same shape as an internal profile bundle), plus a trailing logical customized element.

Arguments

profile

A single profile name: one of "browser", "whatwg", "rfc-syntax", "seo", or the "seo" alias "canonical".

...

Optional explicit knob overrides (e.g. scheme_policy = "require"), named as in safe_parse_url. Each override that the profile also sets replaces the profile's value and marks the result customized.

Normalization versus editorial knobs in <code>"seo"</code>

The bundle applies two kinds of transform, and a reader cannot tell them apart from the profile name alone (RUL-017). Normalization is what a standard says yields the same resource: the WHATWG parse with its dot-segment resolution (url_standard = "whatwg"), host case folding and UTS #46 rendering (host_encoding = "unicode"), and removal of a default port only (port_handling = "strip_default"). Editorial is a claim about how the site is configured that no standard settles: forcing https (protocol_handling), folding www. (www_handling), stripping a trailing slash (trailing_slash_handling) and a terminal index page (index_page_handling), and dropping the whole query (query_handling = "drop"). Each editorial knob can change the addressed resource, and each is in the bundle on purpose: an SEO bundle exists to say which URL a page should be known as, which is a site policy. Pass any knob explicitly to turn it off, and use get_url_key when you need resource identity rather than a display string.

Details

Profiles are inspectable sugar that bundle the parser's acceptance, interpretation, leniency, and canonicalization axes under one name. Explicit arguments always override the profile (the iron rule); when any override is supplied, the resolved result is flagged customized = TRUE and rurl no longer claims the result matches the named profile exactly.

The recognized profiles are "browser" (browser-like http-prepending fix-up posture; not Chrome-faithful), "whatwg" (absolute-URL, no-base spec posture that rejects scheme-less input), "rfc-syntax" (RFC 3986 generic syntax as parsing, not normalization: case and dot-segments are preserved), and "seo" (rurl's origin-cleaning intent; "canonical" is an alias resolving identically to "seo").

"seo" delivers rurl's definition of a clean URL: a lossy policy projection of a WHATWG-parsed URL (ADR 0017), never a separate, weaker construction. It selects url_standard = "whatwg" as the identity underneath — which is also what resolves . and .. folder segments — and host_encoding = "unicode", so the host is canonical in one direction regardless of whether the input spelled it in Unicode or Punycode. The remaining knobs are the projection: https, strip www, trailing slash and index page, drop the whole query, and drop a default port only (port_handling = "strip_default"): a non-default port such as :8080 names a different origin and survives (RFC 3986 §6.2.3; WHATWG URL Standard port state; RFC 6454 §4; RUL-016). The result makes no claim of resource equivalence and is not an HTML canonical URL — forcing https, stripping www and dropping the query can each change the resource addressed. As always, an explicit argument overrides the bundle, so query_handling = "filter" still buys tracker-only removal.

See Also

safe_parse_url, get_scheme_class

Examples

Run this code
url_profile("browser")
url_profile("seo")
# canonical is an alias of seo:
identical(url_profile("canonical"), url_profile("seo"))
# explicit overrides win and flag the result customized:
url_profile("browser", scheme_policy = "require")

Run the code above in your browser using DataLab