Parse a URI string into its elements
parseURI.RdThis breaks a URI given as a string into its different elements such as protocol/scheme, host, port, file name, query. This information can be used, for example, when constructing URIs relative to a base URI.
The return value is an S3-style object of class URI.
This function uses libxml routines to perform the parsing.
Value
A list with 8 elements
- scheme
the name of the protocol being used, http, ftp as a string.
- authority
a string represeting a rarely used aspect of URIs
- server
a string identifying the host, e.g. www.omegahat.net
- user
a string giving the name of the user, e.g. in FTP "ftp://duncan@www.omegahat.net", this would yield "duncan"
- path
a string identifying the path of the target file
- query
the CGI query part of the string, e.g. the bit after '?' of the form
name=value&name=value- fragment
a string giving the coo
- port
an integer identifying the port number on which the connection is to be made
Examples
if (FALSE) ## site is flaky
parseURI("https://www.omegahat.net:8080/RCurl/index.html")
parseURI("ftp://duncan@www.omegahat.net:8080/RCurl/index.html")
#> $scheme
#> [1] "ftp"
#>
#> $authority
#> [1] ""
#>
#> $server
#> [1] "www.omegahat.net"
#>
#> $user
#> [1] "duncan"
#>
#> $path
#> [1] "/RCurl/index.html"
#>
#> $query
#> [1] ""
#>
#> $fragment
#> [1] ""
#>
#> $port
#> [1] 8080
#>
#> attr(,"class")
#> [1] "URI"
parseURI("ftp://duncan@www.omegahat.net:8080/RCurl/index.html#my_anchor")
#> $scheme
#> [1] "ftp"
#>
#> $authority
#> [1] ""
#>
#> $server
#> [1] "www.omegahat.net"
#>
#> $user
#> [1] "duncan"
#>
#> $path
#> [1] "/RCurl/index.html"
#>
#> $query
#> [1] ""
#>
#> $fragment
#> [1] "my_anchor"
#>
#> $port
#> [1] 8080
#>
#> attr(,"class")
#> [1] "URI"
as(parseURI("http://duncan@www.omegahat.net:8080/RCurl/index.html#my_anchor"), "character")
#> [1] "http://duncan@www.omegahat.net:8080/RCurl/index.html#my_anchor"
as(parseURI("ftp://duncan@www.omegahat.net:8080/RCurl/index.html?foo=1&bar=axd"), "character")
#> [1] "ftp://duncan@www.omegahat.net:8080/RCurl/index.html?foo=1&bar=axd"
# \dontrun{}