See https://tools.ietf.org/html/rfc3986 for details of parsing algorithm.
parse_url(url) build_url(url)
| url | For |
|---|
a list containing:
scheme
hostname
port
path
params
fragment
query, a list
username
password
parse_url("http://google.com/")#> $scheme #> [1] "http" #> #> $hostname #> [1] "google.com" #> #> $port #> NULL #> #> $path #> [1] "" #> #> $query #> NULL #> #> $params #> NULL #> #> $fragment #> NULL #> #> $username #> NULL #> #> $password #> NULL #> #> attr(,"class") #> [1] "url"parse_url("http://google.com:80/")#> $scheme #> [1] "http" #> #> $hostname #> [1] "google.com" #> #> $port #> [1] "80" #> #> $path #> [1] "" #> #> $query #> NULL #> #> $params #> NULL #> #> $fragment #> NULL #> #> $username #> NULL #> #> $password #> NULL #> #> attr(,"class") #> [1] "url"parse_url("http://google.com:80/?a=1&b=2")#> $scheme #> [1] "http" #> #> $hostname #> [1] "google.com" #> #> $port #> [1] "80" #> #> $path #> [1] "" #> #> $query #> $query$a #> [1] "1" #> #> $query$b #> [1] "2" #> #> #> $params #> NULL #> #> $fragment #> NULL #> #> $username #> NULL #> #> $password #> NULL #> #> attr(,"class") #> [1] "url"url <- parse_url("http://google.com/") url$scheme <- "https" url$query <- list(q = "hello") build_url(url)#> [1] "https://google.com/?q=hello"