Skip to content

Commit ad23cd5

Browse files
authored
Update parse_url() to be compatible with NNG 2.0 (#210)
1 parent 5c7bafa commit ad23cd5

File tree

5 files changed

+20
-27
lines changed

5 files changed

+20
-27
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# nanonext (development version)
22

3+
#### Updates
4+
5+
* `parse_url()` drops 'rawurl', 'host' and 'requri' from the output vector as these can be derived from the other parts.
6+
37
# nanonext 1.7.1
48

59
#### Updates

R/utils.R

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,19 @@ random <- function(n = 1L, convert = TRUE) .Call(rnng_random, n, convert)
114114
#'
115115
#' @param url character string containing a URL.
116116
#'
117-
#' @return A named character vector of length 10, comprising:
117+
#' @return A named character vector of length 7, comprising:
118118
#' \itemize{
119-
#' \item `rawurl` - the unparsed URL string.
120119
#' \item `scheme` - the URL scheme, such as "http" or "inproc" (always lower
121120
#' case).
122-
#' \item `userinfo` - the username and password if supplied in the URL
123-
#' string.
124-
#' \item `host` - the full host part of the URL, including the port if
125-
#' present (separated by a colon).
121+
#' \item `userinfo` - the username and password (if supplied in the URL
122+
#' string).
126123
#' \item `hostname` - the name of the host.
127124
#' \item `port` - the port (if not specified, the default port if defined by
128125
#' the scheme).
129126
#' \item `path` - the path, typically used with HTTP or WebSocket.
130127
#' \item `query` - the query info (typically following ? in the URL).
131128
#' \item `fragment` - used for specifying an anchor, the part after # in a
132129
#' URL.
133-
#' \item `requri` - the full Request-URI (path\[?query\]\[#fragment\]).
134130
#' }
135131
#' Values that cannot be determined are represented by an empty string `""`.
136132
#'

man/parse_url.Rd

Lines changed: 3 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,16 @@ SEXP rnng_url_parse(SEXP url) {
4949
ERROR_OUT(xc);
5050

5151
SEXP out;
52-
const char *names[] = {"rawurl", "scheme", "userinfo", "host", "hostname",
53-
"port", "path", "query", "fragment", "requri", ""};
52+
const char *names[] = {"scheme", "userinfo", "hostname", "port", "path",
53+
"query", "fragment", ""};
5454
PROTECT(out = Rf_mkNamed(STRSXP, names));
55-
SET_STRING_ELT(out, 0, Rf_mkChar(urlp->u_rawurl));
56-
SET_STRING_ELT(out, 1, Rf_mkChar(urlp->u_scheme == NULL ? "" : urlp->u_scheme));
57-
SET_STRING_ELT(out, 2, Rf_mkChar(urlp->u_userinfo == NULL ? "" : urlp->u_userinfo));
58-
SET_STRING_ELT(out, 3, Rf_mkChar(urlp->u_host == NULL ? "" : urlp->u_host));
59-
SET_STRING_ELT(out, 4, Rf_mkChar(urlp->u_hostname == NULL ? "" : urlp->u_hostname));
60-
SET_STRING_ELT(out, 5, Rf_mkChar(urlp->u_port == NULL ? "" : urlp->u_port));
61-
SET_STRING_ELT(out, 6, Rf_mkChar(urlp->u_path == NULL ? "" : urlp->u_path));
62-
SET_STRING_ELT(out, 7, Rf_mkChar(urlp->u_query == NULL ? "" : urlp->u_query));
63-
SET_STRING_ELT(out, 8, Rf_mkChar(urlp->u_fragment == NULL ? "" : urlp->u_fragment));
64-
SET_STRING_ELT(out, 9, Rf_mkChar(urlp->u_requri == NULL ? "" : urlp->u_requri));
55+
SET_STRING_ELT(out, 0, Rf_mkChar(urlp->u_scheme == NULL ? "" : urlp->u_scheme));
56+
SET_STRING_ELT(out, 1, Rf_mkChar(urlp->u_userinfo == NULL ? "" : urlp->u_userinfo));
57+
SET_STRING_ELT(out, 2, Rf_mkChar(urlp->u_hostname == NULL ? "" : urlp->u_hostname));
58+
SET_STRING_ELT(out, 3, Rf_mkChar(urlp->u_port == NULL ? "" : urlp->u_port));
59+
SET_STRING_ELT(out, 4, Rf_mkChar(urlp->u_path == NULL ? "" : urlp->u_path));
60+
SET_STRING_ELT(out, 5, Rf_mkChar(urlp->u_query == NULL ? "" : urlp->u_query));
61+
SET_STRING_ELT(out, 6, Rf_mkChar(urlp->u_fragment == NULL ? "" : urlp->u_fragment));
6562
nng_url_free(urlp);
6663

6764
UNPROTECT(1);

tests/tests.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ test_null(msleep(1))
499499
test_null(msleep("a"))
500500
test_null(msleep(-1L))
501501
test_type("character", urlp <- parse_url("://"))
502-
test_equal(length(urlp), 10L)
502+
test_equal(length(urlp), 7L)
503503
test_true(all(nzchar(parse_url("wss://use:r@[::1]/path?q=1#name"))))
504504
test_type("character", random())
505505
test_equal(nchar(random(2)), 4L)

0 commit comments

Comments
 (0)