Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #30 #37

Merged
merged 4 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,44 +37,44 @@ Rcpp_ada_has_search <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_has_search`, url_vec)
}

Rcpp_ada_get_href <- function(input_vec, length_vec) {
.Call(`_adaR_Rcpp_ada_get_href`, input_vec, length_vec)
Rcpp_ada_get_href <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_href`, url_vec)
}

Rcpp_ada_get_username <- function(input_vec, length_vec) {
.Call(`_adaR_Rcpp_ada_get_username`, input_vec, length_vec)
Rcpp_ada_get_username <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_username`, url_vec)
}

Rcpp_ada_get_password <- function(input_vec, length_vec) {
.Call(`_adaR_Rcpp_ada_get_password`, input_vec, length_vec)
Rcpp_ada_get_password <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_password`, url_vec)
}

Rcpp_ada_get_port <- function(input_vec, length_vec) {
.Call(`_adaR_Rcpp_ada_get_port`, input_vec, length_vec)
Rcpp_ada_get_port <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_port`, url_vec)
}

Rcpp_ada_get_hash <- function(input_vec, length_vec) {
.Call(`_adaR_Rcpp_ada_get_hash`, input_vec, length_vec)
Rcpp_ada_get_hash <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_hash`, url_vec)
}

Rcpp_ada_get_host <- function(input_vec, length_vec) {
.Call(`_adaR_Rcpp_ada_get_host`, input_vec, length_vec)
Rcpp_ada_get_host <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_host`, url_vec)
}

Rcpp_ada_get_hostname <- function(input_vec, length_vec) {
.Call(`_adaR_Rcpp_ada_get_hostname`, input_vec, length_vec)
Rcpp_ada_get_hostname <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_hostname`, url_vec)
}

Rcpp_ada_get_pathname <- function(input_vec, length_vec) {
.Call(`_adaR_Rcpp_ada_get_pathname`, input_vec, length_vec)
Rcpp_ada_get_pathname <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_pathname`, url_vec)
}

Rcpp_ada_get_search <- function(input_vec, length_vec) {
.Call(`_adaR_Rcpp_ada_get_search`, input_vec, length_vec)
Rcpp_ada_get_search <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_search`, url_vec)
}

Rcpp_ada_get_protocol <- function(input_vec, length_vec) {
.Call(`_adaR_Rcpp_ada_get_protocol`, input_vec, length_vec)
Rcpp_ada_get_protocol <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_get_protocol`, url_vec)
}

#' Function to percent-decode characters in URLs
Expand Down
160 changes: 46 additions & 114 deletions R/get.R
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)
}
22 changes: 0 additions & 22 deletions man/ada_get_hash.Rd

This file was deleted.

22 changes: 0 additions & 22 deletions man/ada_get_host.Rd

This file was deleted.

22 changes: 0 additions & 22 deletions man/ada_get_hostname.Rd

This file was deleted.

Loading