Concatenate strings to form a URL
Usage
pasteUrl(..., protocol = c("none", "https", "http", "ftp", "rsync", "s3"))
Arguments
- ...
Character strings. Intentionally does not support recycling here, unlike base
paste
. Input of character vector as first argument alone is supported. Errors ifNA
values are present.- protocol
character(1)
. Desired protocol to use. Defaults to "https" but "http", "ftp", and "s3" (AWS S3) are also supported. Use"none"
if you want to prepare a URL that already contains a protocol in the first element of the dots.
Details
Encoding is applied automatically via utils::URLencode
.
Examples
## HTTPS.
x <- pasteUrl(
"r.acidgenomics.com",
"packages",
"acidbase",
protocol = "https"
)
print(x)
#> [1] "https://r.acidgenomics.com/packages/acidbase"
## FTP.
x <- pasteUrl(
"ftp.ensembl.org",
"pub",
"release-94",
"gtf",
"homo_sapiens",
"Homo_sapiens.GRCh38.94.gtf.gz",
protocol = "ftp"
)
print(x)
#> [1] "ftp://ftp.ensembl.org/pub/release-94/gtf/homo_sapiens/Homo_sapiens.GRCh38.94.gtf.gz"
## Automatic encoding support.
x <- pasteUrl(
"rest.ensembl.org",
"info",
"assembly",
"Homo sapiens",
protocol = "https"
)
print(x)
#> [1] "https://rest.ensembl.org/info/assembly/Homo%20sapiens"
## Character vector support.
vec <- c("r.acidgenomics.com", "packages", "acidbase")
x <- pasteUrl(vec, protocol = "https")
print(x)
#> [1] "https://r.acidgenomics.com/packages/acidbase"