Skip to content

Commit

Permalink
Use the silent conversion approach fix #66
Browse files Browse the repository at this point in the history
See #68 and #67

This passes the basic tests.
  • Loading branch information
chainsawriot committed Jan 31, 2024
1 parent 0ac03d0 commit 94fa964
Show file tree
Hide file tree
Showing 13 changed files with 288 additions and 352 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BugReports: https://github.com/gesistsa/adaR/issues
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.0
RoxygenNote: 7.3.1
LinkingTo:
Rcpp
Imports:
Expand Down
96 changes: 48 additions & 48 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

Rcpp_ada_parse <- function(input_vec, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_parse`, input_vec, decode, to_unicode)
Rcpp_ada_parse <- function(input_vec, decode) {
.Call(`_adaR_Rcpp_ada_parse`, input_vec, decode)
}

Rcpp_ada_has_credentials <- function(url_vec) {
Expand Down Expand Up @@ -37,96 +37,96 @@ Rcpp_ada_has_search <- function(url_vec) {
.Call(`_adaR_Rcpp_ada_has_search`, url_vec)
}

Rcpp_ada_get_href <- function(url_vec, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_get_href`, url_vec, decode, to_unicode)
Rcpp_ada_get_href <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_href`, url_vec, decode)
}

Rcpp_ada_get_username <- function(url_vec, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_get_username`, url_vec, decode, to_unicode)
Rcpp_ada_get_username <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_username`, url_vec, decode)
}

Rcpp_ada_get_password <- function(url_vec, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_get_password`, url_vec, decode, to_unicode)
Rcpp_ada_get_password <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_password`, url_vec, decode)
}

Rcpp_ada_get_port <- function(url_vec, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_get_port`, url_vec, decode, to_unicode)
Rcpp_ada_get_port <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_port`, url_vec, decode)
}

Rcpp_ada_get_hash <- function(url_vec, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_get_hash`, url_vec, decode, to_unicode)
Rcpp_ada_get_hash <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_hash`, url_vec, decode)
}

Rcpp_ada_get_host <- function(url_vec, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_get_host`, url_vec, decode, to_unicode)
Rcpp_ada_get_host <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_host`, url_vec, decode)
}

Rcpp_ada_get_hostname <- function(url_vec, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_get_hostname`, url_vec, decode, to_unicode)
Rcpp_ada_get_hostname <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_hostname`, url_vec, decode)
}

Rcpp_ada_get_pathname <- function(url_vec, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_get_pathname`, url_vec, decode, to_unicode)
Rcpp_ada_get_pathname <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_pathname`, url_vec, decode)
}

Rcpp_ada_get_search <- function(url_vec, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_get_search`, url_vec, decode, to_unicode)
Rcpp_ada_get_search <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_search`, url_vec, decode)
}

Rcpp_ada_get_protocol <- function(url_vec, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_get_protocol`, url_vec, decode, to_unicode)
Rcpp_ada_get_protocol <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_protocol`, url_vec, decode)
}

Rcpp_ada_set_href <- function(url_vec, subst, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_set_href`, url_vec, subst, decode, to_unicode)
Rcpp_ada_set_href <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_href`, url_vec, subst, decode)
}

Rcpp_ada_set_username <- function(url_vec, subst, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_set_username`, url_vec, subst, decode, to_unicode)
Rcpp_ada_set_username <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_username`, url_vec, subst, decode)
}

Rcpp_ada_set_password <- function(url_vec, subst, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_set_password`, url_vec, subst, decode, to_unicode)
Rcpp_ada_set_password <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_password`, url_vec, subst, decode)
}

Rcpp_ada_set_port <- function(url_vec, subst, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_set_port`, url_vec, subst, decode, to_unicode)
Rcpp_ada_set_port <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_port`, url_vec, subst, decode)
}

Rcpp_ada_set_host <- function(url_vec, subst, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_set_host`, url_vec, subst, decode, to_unicode)
Rcpp_ada_set_host <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_host`, url_vec, subst, decode)
}

Rcpp_ada_set_hostname <- function(url_vec, subst, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_set_hostname`, url_vec, subst, decode, to_unicode)
Rcpp_ada_set_hostname <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_hostname`, url_vec, subst, decode)
}

Rcpp_ada_set_pathname <- function(url_vec, subst, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_set_pathname`, url_vec, subst, decode, to_unicode)
Rcpp_ada_set_pathname <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_pathname`, url_vec, subst, decode)
}

Rcpp_ada_set_protocol <- function(url_vec, subst, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_set_protocol`, url_vec, subst, decode, to_unicode)
Rcpp_ada_set_protocol <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_protocol`, url_vec, subst, decode)
}

Rcpp_ada_set_search <- function(url_vec, subst, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_set_search`, url_vec, subst, decode, to_unicode)
Rcpp_ada_set_search <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_search`, url_vec, subst, decode)
}

Rcpp_ada_set_hash <- function(url_vec, subst, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_set_hash`, url_vec, subst, decode, to_unicode)
Rcpp_ada_set_hash <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_hash`, url_vec, subst, decode)
}

Rcpp_ada_clear_port <- function(url_vec, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_clear_port`, url_vec, decode, to_unicode)
Rcpp_ada_clear_port <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_clear_port`, url_vec, decode)
}

Rcpp_ada_clear_hash <- function(url_vec, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_clear_hash`, url_vec, decode, to_unicode)
Rcpp_ada_clear_hash <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_clear_hash`, url_vec, decode)
}

Rcpp_ada_clear_search <- function(url_vec, decode, to_unicode) {
.Call(`_adaR_Rcpp_ada_clear_search`, url_vec, decode, to_unicode)
Rcpp_ada_clear_search <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_clear_search`, url_vec, decode)
}

Rcpp_url_decode2 <- function(url) {
Expand Down
16 changes: 8 additions & 8 deletions R/clear.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.clear <- function(url, decode, func, to_unicode) {
.clear <- function(url, decode, func) {
if (is.null(url)) {
return(character(0))
}
func(url, decode, to_unicode)
func(url, decode)
}

#' Clear a specific component of URL
Expand All @@ -16,18 +16,18 @@
#' ada_clear_hash(url)
#' ada_clear_search(url)
#' @export
ada_clear_port <- function(url, decode = TRUE, to_unicode = TRUE) {
.clear(url, decode, Rcpp_ada_clear_port, to_unicode)
ada_clear_port <- function(url, decode = TRUE) {
.clear(url, decode, Rcpp_ada_clear_port)
}

#' @rdname ada_clear_port
#' @export
ada_clear_hash <- function(url, decode = TRUE, to_unicode = TRUE) {
.clear(url, decode, Rcpp_ada_clear_hash, to_unicode)
ada_clear_hash <- function(url, decode = TRUE) {
.clear(url, decode, Rcpp_ada_clear_hash)
}

#' @rdname ada_clear_port
#' @export
ada_clear_search <- function(url, decode = TRUE, to_unicode = TRUE) {
.clear(url, decode, Rcpp_ada_clear_search, to_unicode)
ada_clear_search <- function(url, decode = TRUE) {
.clear(url, decode, Rcpp_ada_clear_search)
}
44 changes: 22 additions & 22 deletions R/get.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.get <- function(url, decode, func, to_unicode) {
.get <- function(url, decode, func) {
if (is.null(url)) {
return(character(0))
}
func(url, decode, to_unicode)
func(url, decode)
}

#' Get a specific component of URL
Expand All @@ -28,62 +28,62 @@
#' urls <- c("http://www.google.com", "http://www.google.com:80", "noturl")
#' ada_get_port(urls)
#' @export
ada_get_href <- function(url, decode = TRUE, to_unicode = TRUE) {
.get(url, decode, Rcpp_ada_get_href, to_unicode)
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, to_unicode = TRUE) {
.get(url, decode, Rcpp_ada_get_username, to_unicode)
ada_get_username <- function(url, decode = TRUE) {
.get(url, decode, Rcpp_ada_get_username)
}

#' @rdname ada_get_href
#' @export
ada_get_password <- function(url, decode = TRUE, to_unicode = TRUE) {
.get(url, decode, Rcpp_ada_get_password, to_unicode)
ada_get_password <- function(url, decode = TRUE) {
.get(url, decode, Rcpp_ada_get_password)
}

#' @rdname ada_get_href
#' @export
ada_get_port <- function(url, decode = TRUE, to_unicode = TRUE) {
.get(url, decode, Rcpp_ada_get_port, to_unicode)
ada_get_port <- function(url, decode = TRUE) {
.get(url, decode, Rcpp_ada_get_port)
}

#' @rdname ada_get_href
#' @export
ada_get_hash <- function(url, decode = TRUE, to_unicode = TRUE) {
.get(url, decode, Rcpp_ada_get_hash, to_unicode)
ada_get_hash <- function(url, decode = TRUE) {
.get(url, decode, Rcpp_ada_get_hash)
}

#' @rdname ada_get_href
#' @export
ada_get_host <- function(url, decode = TRUE, to_unicode = TRUE) {
.get(url, decode, Rcpp_ada_get_host, to_unicode)
ada_get_host <- function(url, decode = TRUE) {
.get(url, decode, Rcpp_ada_get_host)
}

#' @rdname ada_get_href
#' @export
ada_get_hostname <- function(url, decode = TRUE, to_unicode = TRUE) {
.get(url, decode, Rcpp_ada_get_hostname, to_unicode)
ada_get_hostname <- function(url, decode = TRUE) {
.get(url, decode, Rcpp_ada_get_hostname)
}

#' @rdname ada_get_href
#' @export
ada_get_pathname <- function(url, decode = TRUE, to_unicode = TRUE) {
.get(url, decode, Rcpp_ada_get_pathname, to_unicode)
ada_get_pathname <- function(url, decode = TRUE) {
.get(url, decode, Rcpp_ada_get_pathname)
}

#' @rdname ada_get_href
#' @export
ada_get_search <- function(url, decode = TRUE, to_unicode = TRUE) {
.get(url, decode, Rcpp_ada_get_search, to_unicode)
ada_get_search <- function(url, decode = TRUE) {
.get(url, decode, Rcpp_ada_get_search)
}

#' @rdname ada_get_href
#' @export
ada_get_protocol <- function(url, decode = TRUE, to_unicode = TRUE) {
.get(url, decode, Rcpp_ada_get_protocol, to_unicode)
ada_get_protocol <- function(url, decode = TRUE) {
.get(url, decode, Rcpp_ada_get_protocol)
}

R_ada_get_domain <- function(url) {
Expand Down
6 changes: 2 additions & 4 deletions R/parse.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#' Use ada-url to parse a url
#' @param url character. one or more URL to be parsed
#' @param decode logical. Whether to decode the output (see [utils::URLdecode()]), default to `TRUE`
#' @param to_unicode logical. Whether to convert the output to unicode. default
#' is TRUE
#' @details For details on the returned components refer to the introductory vignette.
#' @return A data frame of the url components:
#' href, protocol, username, password, host, hostname, port, pathname, search, and hash
#' @examples
#' ada_url_parse("https://user_1:[email protected]:8080/dir/../api?q=1#frag")
#' @export
ada_url_parse <- function(url, decode = TRUE, to_unicode = TRUE) {
ada_url_parse <- function(url, decode = TRUE) {
if (is.null(url)) {
return(structure(list(
href = character(0), protocol = character(0),
Expand All @@ -18,7 +16,7 @@ ada_url_parse <- function(url, decode = TRUE, to_unicode = TRUE) {
search = character(0), hash = character(0)
), row.names = integer(0), class = "data.frame"))
}
Rcpp_ada_parse(url, decode, to_unicode)
Rcpp_ada_parse(url, decode)
}

#' Function to percent-decode characters in URLs
Expand Down
Loading

0 comments on commit 94fa964

Please sign in to comment.