Skip to content
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
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# nanonext (development version)

#### Updates

* `parse_url()` drops 'rawurl', 'host' and 'requri' from the output vector as these can be derived from the other parts.

# nanonext 1.7.1

#### Updates
Expand Down
10 changes: 3 additions & 7 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,19 @@ random <- function(n = 1L, convert = TRUE) .Call(rnng_random, n, convert)
#'
#' @param url character string containing a URL.
#'
#' @return A named character vector of length 10, comprising:
#' @return A named character vector of length 7, comprising:
#' \itemize{
#' \item `rawurl` - the unparsed URL string.
#' \item `scheme` - the URL scheme, such as "http" or "inproc" (always lower
#' case).
#' \item `userinfo` - the username and password if supplied in the URL
#' string.
#' \item `host` - the full host part of the URL, including the port if
#' present (separated by a colon).
#' \item `userinfo` - the username and password (if supplied in the URL
#' string).
#' \item `hostname` - the name of the host.
#' \item `port` - the port (if not specified, the default port if defined by
#' the scheme).
#' \item `path` - the path, typically used with HTTP or WebSocket.
#' \item `query` - the query info (typically following ? in the URL).
#' \item `fragment` - used for specifying an anchor, the part after # in a
#' URL.
#' \item `requri` - the full Request-URI (path\[?query\]\[#fragment\]).
#' }
#' Values that cannot be determined are represented by an empty string `""`.
#'
Expand Down
10 changes: 3 additions & 7 deletions man/parse_url.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 9 additions & 12 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,16 @@ SEXP rnng_url_parse(SEXP url) {
ERROR_OUT(xc);

SEXP out;
const char *names[] = {"rawurl", "scheme", "userinfo", "host", "hostname",
"port", "path", "query", "fragment", "requri", ""};
const char *names[] = {"scheme", "userinfo", "hostname", "port", "path",
"query", "fragment", ""};
PROTECT(out = Rf_mkNamed(STRSXP, names));
SET_STRING_ELT(out, 0, Rf_mkChar(urlp->u_rawurl));
SET_STRING_ELT(out, 1, Rf_mkChar(urlp->u_scheme == NULL ? "" : urlp->u_scheme));
SET_STRING_ELT(out, 2, Rf_mkChar(urlp->u_userinfo == NULL ? "" : urlp->u_userinfo));
SET_STRING_ELT(out, 3, Rf_mkChar(urlp->u_host == NULL ? "" : urlp->u_host));
SET_STRING_ELT(out, 4, Rf_mkChar(urlp->u_hostname == NULL ? "" : urlp->u_hostname));
SET_STRING_ELT(out, 5, Rf_mkChar(urlp->u_port == NULL ? "" : urlp->u_port));
SET_STRING_ELT(out, 6, Rf_mkChar(urlp->u_path == NULL ? "" : urlp->u_path));
SET_STRING_ELT(out, 7, Rf_mkChar(urlp->u_query == NULL ? "" : urlp->u_query));
SET_STRING_ELT(out, 8, Rf_mkChar(urlp->u_fragment == NULL ? "" : urlp->u_fragment));
SET_STRING_ELT(out, 9, Rf_mkChar(urlp->u_requri == NULL ? "" : urlp->u_requri));
SET_STRING_ELT(out, 0, Rf_mkChar(urlp->u_scheme == NULL ? "" : urlp->u_scheme));
SET_STRING_ELT(out, 1, Rf_mkChar(urlp->u_userinfo == NULL ? "" : urlp->u_userinfo));
SET_STRING_ELT(out, 2, Rf_mkChar(urlp->u_hostname == NULL ? "" : urlp->u_hostname));
SET_STRING_ELT(out, 3, Rf_mkChar(urlp->u_port == NULL ? "" : urlp->u_port));
SET_STRING_ELT(out, 4, Rf_mkChar(urlp->u_path == NULL ? "" : urlp->u_path));
SET_STRING_ELT(out, 5, Rf_mkChar(urlp->u_query == NULL ? "" : urlp->u_query));
SET_STRING_ELT(out, 6, Rf_mkChar(urlp->u_fragment == NULL ? "" : urlp->u_fragment));
nng_url_free(urlp);

UNPROTECT(1);
Expand Down
2 changes: 1 addition & 1 deletion tests/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ test_null(msleep(1))
test_null(msleep("a"))
test_null(msleep(-1L))
test_type("character", urlp <- parse_url("://"))
test_equal(length(urlp), 10L)
test_equal(length(urlp), 7L)
test_true(all(nzchar(parse_url("wss://use:r@[::1]/path?q=1#name"))))
test_type("character", random())
test_equal(nchar(random(2)), 4L)
Expand Down
Loading