Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

getRelativeURL

Compute name of URL relative to a base URL


Description

This function is a convenience function for computing the fullly qualified URI of a document relative to a base URL. It handles the case where the document is already fully qualified and so ignores the base URL or, alternatively, is a relative document name and so prepends the base URL. It does not (yet) try to be clever by collapsing relative directories such as "..".

Usage

getRelativeURL(u, baseURL, sep = "/", addBase = TRUE,
               simplify = TRUE, escapeQuery = FALSE)

Arguments

u

the location of the target document whose fully qualified URI is to be determined.

baseURL

the base URL relative to which the value of u should be interpreted.

sep

the separator to use to separate elements of the path. For external URLs (e.g. accessed via HTTP, HTTPS, FTP), / should be used. For local files on Windows machines one might use .Platform$file.sep, but this is incorrect unless one knows that the resulting file is to be accessed using Windows file system notation, i.e. C:\\my\\folder\\file.

addBase

a logical controlling whether we prepend the base URL to the result.

simplify

a logical value that controls whether we attempt to simplify/normalize the path to remove .. and .

escapeQuery

a logical value. Currently ignored.

Details

This uses the function parseURI to compute the components of the different URIs.

Value

A character string giving the fully qualified URI for u.

Author(s)

Duncan Temple Lang

See Also

parseURI which uses the libxml2 facilities for parsing URIs.

xmlParse, xmlTreeParse, xmlInternalTreeParse. XInclude and XML Schema import/include elements for computing relative locations of included/imported files..

Examples

getRelativeURL("http://www.omegahat.net", "http://www.r-project.org")

 getRelativeURL("bar.html", "http://www.r-project.org/")

 getRelativeURL("../bar.html", "http://www.r-project.org/")

XML

Tools for Parsing and Generating XML Within R and S-Plus

v3.99-0.10
BSD_3_clause + file LICENSE
Authors
CRAN Team [ctb, cre] (de facto maintainer since 2013), Duncan Temple Lang [aut] (<https://orcid.org/0000-0003-0159-1546>), Tomas Kalibera [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.