-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from chainsawriot/fixget
Fix #30
- Loading branch information
Showing
15 changed files
with
225 additions
and
560 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,157 +1,89 @@ | ||
#' Get href component of URL | ||
#' @inheritParams ada_url_parse | ||
#' @return logical | ||
#' @examples | ||
#' ada_get_href("https://user_1:[email protected]:8080/dir/../api?q=1#frag") | ||
#' @export | ||
ada_get_href <- function(url, decode = TRUE) { | ||
len <- vapply(url, function(x) nchar(x, type = "bytes"), integer(1), USE.NAMES = FALSE) | ||
out <- Rcpp_ada_get_href(url, len) | ||
.get <- function(url, decode, func) { | ||
if (is.null(url)) { | ||
return(character(0)) | ||
} | ||
out <- func(url) | ||
if (isTRUE(decode)) { | ||
return(url_decode2(out)) | ||
} | ||
return(out) | ||
} | ||
|
||
#' Get username component of URL | ||
#' Get a specific component of URL | ||
#' | ||
#' These functions get a specific component of URL. | ||
#' @inheritParams ada_url_parse | ||
#' @return logical | ||
#' @return character, `NA` if not a valid URL | ||
#' @examples | ||
#' ada_get_username("https://user_1:[email protected]:8080/dir/../api?q=1#frag") | ||
#' url <- "https://user_1:[email protected]:8080/dir/../api?q=1#frag" | ||
#' ada_get_href(url) | ||
#' ada_get_username(url) | ||
#' ada_get_password(url) | ||
#' ada_get_port(url) | ||
#' ada_get_hash(url) | ||
#' ada_get_host(url) | ||
#' ada_get_hostname(url) | ||
#' ada_get_pathname(url) | ||
#' ada_get_search(url) | ||
#' ada_get_protocol(url) | ||
#' ## these functions are vectorized | ||
#' urls <- c("http://www.google.com", "http://www.google.com:80", "noturl") | ||
#' ada_get_port(urls) | ||
#' @export | ||
ada_get_username <- function(url, decode = TRUE) { | ||
len <- vapply(url, function(x) nchar(x, type = "bytes"), integer(1), USE.NAMES = FALSE) | ||
out <- Rcpp_ada_get_username(url, len) | ||
if (isTRUE(decode)) { | ||
return(url_decode2(out)) | ||
} | ||
return(out) | ||
ada_get_href <- function(url, decode = TRUE) { | ||
.get(url, decode, Rcpp_ada_get_href) | ||
} | ||
|
||
#' @rdname ada_get_href | ||
#' @export | ||
ada_get_username <- function(url, decode = TRUE) { | ||
.get(url, decode, Rcpp_ada_get_username) | ||
} | ||
|
||
#' Get password component of URL | ||
#' @inheritParams ada_url_parse | ||
#' @return logical | ||
#' @examples | ||
#' ada_get_password("https://user_1:[email protected]:8080/dir/../api?q=1#frag") | ||
#' @rdname ada_get_href | ||
#' @export | ||
ada_get_password <- function(url, decode = TRUE) { | ||
len <- vapply(url, function(x) nchar(x, type = "bytes"), integer(1), USE.NAMES = FALSE) | ||
out <- Rcpp_ada_get_password(url, len) | ||
if (isTRUE(decode)) { | ||
return(url_decode2(out)) | ||
} | ||
return(out) | ||
.get(url, decode, Rcpp_ada_get_password) | ||
} | ||
|
||
|
||
#' Get port component of URL | ||
#' @inheritParams ada_url_parse | ||
#' @return logical | ||
#' @examples | ||
#' ada_get_port("https://user_1:[email protected]:8080/dir/../api?q=1#frag") | ||
#' @rdname ada_get_href | ||
#' @export | ||
ada_get_port <- function(url, decode = TRUE) { | ||
len <- vapply(url, function(x) nchar(x, type = "bytes"), integer(1), USE.NAMES = FALSE) | ||
out <- Rcpp_ada_get_port(url, len) | ||
if (isTRUE(decode)) { | ||
return(url_decode2(out)) | ||
} | ||
return(out) | ||
.get(url, decode, Rcpp_ada_get_port) | ||
} | ||
|
||
|
||
#' Get hash component of URL | ||
#' @inheritParams ada_url_parse | ||
#' @return logical | ||
#' @examples | ||
#' ada_get_hash("https://user_1:[email protected]:8080/dir/../api?q=1#frag") | ||
#' @rdname ada_get_href | ||
#' @export | ||
ada_get_hash <- function(url, decode = TRUE) { | ||
len <- vapply(url, function(x) nchar(x, type = "bytes"), integer(1), USE.NAMES = FALSE) | ||
out <- Rcpp_ada_get_hash(url, len) | ||
if (isTRUE(decode)) { | ||
return(url_decode2(out)) | ||
} | ||
return(out) | ||
.get(url, decode, Rcpp_ada_get_hash) | ||
} | ||
|
||
|
||
#' Get host component of URL | ||
#' @inheritParams ada_url_parse | ||
#' @return logical | ||
#' @examples | ||
#' ada_get_host("https://user_1:[email protected]:8080/dir/../api?q=1#frag") | ||
#' @rdname ada_get_href | ||
#' @export | ||
ada_get_host <- function(url, decode = TRUE) { | ||
len <- vapply(url, function(x) nchar(x, type = "bytes"), integer(1), USE.NAMES = FALSE) | ||
out <- Rcpp_ada_get_host(url, len) | ||
if (isTRUE(decode)) { | ||
return(url_decode2(out)) | ||
} | ||
return(out) | ||
.get(url, decode, Rcpp_ada_get_host) | ||
} | ||
|
||
|
||
#' Get hostname component of URL | ||
#' @inheritParams ada_url_parse | ||
#' @return logical | ||
#' @examples | ||
#' ada_get_hostname("https://user_1:[email protected]:8080/dir/../api?q=1#frag") | ||
#' @rdname ada_get_href | ||
#' @export | ||
ada_get_hostname <- function(url, decode = TRUE) { | ||
len <- vapply(url, function(x) nchar(x, type = "bytes"), integer(1), USE.NAMES = FALSE) | ||
out <- Rcpp_ada_get_hostname(url, len) | ||
if (isTRUE(decode)) { | ||
return(url_decode2(out)) | ||
} | ||
return(out) | ||
.get(url, decode, Rcpp_ada_get_hostname) | ||
} | ||
|
||
|
||
#' Get pathname component of URL | ||
#' @inheritParams ada_url_parse | ||
#' @return logical | ||
#' @examples | ||
#' ada_get_pathname("https://user_1:[email protected]:8080/dir/../api?q=1#frag") | ||
#' @rdname ada_get_href | ||
#' @export | ||
ada_get_pathname <- function(url, decode = TRUE) { | ||
len <- vapply(url, function(x) nchar(x, type = "bytes"), integer(1), USE.NAMES = FALSE) | ||
out <- Rcpp_ada_get_pathname(url, len) | ||
if (isTRUE(decode)) { | ||
return(url_decode2(out)) | ||
} | ||
return(out) | ||
.get(url, decode, Rcpp_ada_get_pathname) | ||
} | ||
|
||
|
||
#' Get search component of URL | ||
#' @inheritParams ada_url_parse | ||
#' @return logical | ||
#' @examples | ||
#' ada_get_search("https://user_1:[email protected]:8080/dir/../api?q=1#frag") | ||
#' @rdname ada_get_href | ||
#' @export | ||
ada_get_search <- function(url, decode = TRUE) { | ||
len <- vapply(url, function(x) nchar(x, type = "bytes"), integer(1), USE.NAMES = FALSE) | ||
out <- Rcpp_ada_get_search(url, len) | ||
if (isTRUE(decode)) { | ||
return(url_decode2(out)) | ||
} | ||
return(out) | ||
.get(url, decode, Rcpp_ada_get_search) | ||
} | ||
|
||
|
||
#' Get protocol component of URL | ||
#' @inheritParams ada_url_parse | ||
#' @return logical | ||
#' @examples | ||
#' ada_get_protocol("https://user_1:[email protected]:8080/dir/../api?q=1#frag") | ||
#' @rdname ada_get_href | ||
#' @export | ||
ada_get_protocol <- function(url, decode = TRUE) { | ||
len <- vapply(url, function(x) nchar(x, type = "bytes"), integer(1), USE.NAMES = FALSE) | ||
out <- Rcpp_ada_get_protocol(url, len) | ||
if (isTRUE(decode)) { | ||
return(url_decode2(out)) | ||
} | ||
return(out) | ||
.get(url, decode, Rcpp_ada_get_protocol) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.