url_modify | R Documentation |
Use url_modify()
to modify any component of the URL,
url_modify_relative()
to modify with a relative URL,
or url_modify_query()
to modify individual query parameters.
For url_modify()
, components that aren't specified in the
function call will be left as is; components set to NULL
will be removed,
and all other values will be updated. Note that removing scheme
or
hostname
will create a relative URL.
url_modify(
url,
scheme = as_is,
hostname = as_is,
username = as_is,
password = as_is,
port = as_is,
path = as_is,
query = as_is,
fragment = as_is
)
url_modify_relative(url, relative_url)
url_modify_query(
.url,
...,
.multi = c("error", "comma", "pipe", "explode"),
.space = c("percent", "form")
)
url , .url |
A string or parsed URL. |
scheme |
The scheme, typically either |
hostname |
The hostname, e.g., |
username , password |
Username and password to embed in the URL. Not generally recommended but needed for some legacy applications. |
port |
An integer port number. |
path |
The path, e.g., |
query |
Either a query string or a named list of query components. |
fragment |
The fragment, e.g., |
relative_url |
A relative URL to append to the base URL. |
... |
< |
.multi |
Controls what happens when a value is a vector:
If none of these options work for your needs, you can instead supply a function that takes a character vector of argument values and returns a a single string. |
.space |
How should spaces in query params be escaped? The default,
"percent", uses standard percent encoding (i.e. |
An object of the same type as url
.
Other URL manipulation:
url_build()
,
url_parse()
url_modify("http://hadley.nz", path = "about")
url_modify("http://hadley.nz", scheme = "https")
url_modify("http://hadley.nz/abc", path = "/cde")
url_modify("http://hadley.nz/abc", path = "")
url_modify("http://hadley.nz?a=1", query = "b=2")
url_modify("http://hadley.nz?a=1", query = list(c = 3))
url_modify_query("http://hadley.nz?a=1&b=2", c = 3)
url_modify_query("http://hadley.nz?a=1&b=2", b = NULL)
url_modify_query("http://hadley.nz?a=1&b=2", a = 100)
url_modify_relative("http://hadley.nz/a/b/c.html", "/d.html")
url_modify_relative("http://hadley.nz/a/b/c.html", "d.html")
url_modify_relative("http://hadley.nz/a/b/c.html", "../d.html")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.