url_parse: Parse a URL into its component pieces

View source: R/url.R

url_parseR Documentation

Parse a URL into its component pieces

Description

url_parse() parses a URL into its component parts, powered by curl::curl_parse_url(). The parsing algorithm follows the specifications detailed in RFC 3986.

Usage

url_parse(url, base_url = NULL)

Arguments

url

A string containing the URL to parse.

base_url

Use this as a parent, if url is a relative URL.

Value

An S3 object of class httr2_url with the following components: scheme, hostname, username, password, port, path, query, and fragment.

See Also

Other URL manipulation: url_build(), url_modify()

Examples

url_parse("http://google.com/")
url_parse("http://google.com:80/")
url_parse("http://google.com:80/?a=1&b=2")
url_parse("http://username@google.com:80/path;test?a=1&b=2#40")

# You can parse a relative URL if you also provide a base url
url_parse("foo", "http://google.com/bar/")
url_parse("..", "http://google.com/bar/")

r-lib/httr2 documentation built on Jan. 11, 2025, 10:21 a.m.