-
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.
Browse files
Browse the repository at this point in the history
* added to_unicode parameter * added test * Use the silent conversion approach fix #66 See #68 and #67 This passes the basic tests. * A better test suite for #66 * More tests * Head hygiene and default parameter * Bürokratie --------- Co-authored-by: schochastics <[email protected]>
- Loading branch information
1 parent
3b43e60
commit 43284da
Showing
8 changed files
with
93 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: adaR | ||
Title: A Fast 'WHATWG' Compliant URL Parser | ||
Version: 0.3.1 | ||
Version: 0.3.2 | ||
Authors@R: | ||
c(person("David", "Schoch", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0003-2952-4812")), | ||
|
@@ -15,7 +15,7 @@ BugReports: https://github.com/gesistsa/adaR/issues | |
License: MIT + file LICENSE | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.2.3 | ||
RoxygenNote: 7.3.1 | ||
LinkingTo: | ||
Rcpp | ||
Imports: | ||
|
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,3 +1,7 @@ | ||
# adaR 0.3.2 | ||
|
||
* fixed #66 | ||
|
||
# adaR 0.3.1 | ||
|
||
* bumped ada-url to 2.7.3 | ||
|
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
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
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,39 +1,39 @@ | ||
test_that("works with standard url", { | ||
res <- ada_url_parse("https://www.google.de") | ||
expect_equal(res[["href"]], "https://www.google.de/") | ||
expect_equal(res[["host"]], "www.google.de") | ||
res <- ada_url_parse("https://www.google.de/") | ||
expect_equal(res[["href"]], "https://www.google.de/") | ||
expect_equal(res[["host"]], "www.google.de") | ||
}) | ||
|
||
test_that("works with complex url", { | ||
res <- ada_url_parse("https://user_1:[email protected]:8080/dir/../api?q=1#frag") | ||
expect_equal(res[["username"]], "user_1") | ||
expect_equal(res[["password"]], "password_1") | ||
expect_equal(res[["host"]], "example.org:8080") | ||
expect_equal(res[["hostname"]], "example.org") | ||
expect_equal(res[["port"]], "8080") | ||
expect_equal(res[["pathname"]], "/api") | ||
expect_equal(res[["search"]], "?q=1") | ||
expect_equal(res[["hash"]], "#frag") | ||
res <- ada_url_parse("https://user_1:[email protected]:8080/dir/../api?q=1#frag") | ||
expect_equal(res[["username"]], "user_1") | ||
expect_equal(res[["password"]], "password_1") | ||
expect_equal(res[["host"]], "example.org:8080") | ||
expect_equal(res[["hostname"]], "example.org") | ||
expect_equal(res[["port"]], "8080") | ||
expect_equal(res[["pathname"]], "/api") | ||
expect_equal(res[["search"]], "?q=1") | ||
expect_equal(res[["hash"]], "#frag") | ||
}) | ||
|
||
test_that("works with utf8", { | ||
res <- ada_url_parse("https://www.hk01.com/zone/1/\u6e2f\u805e") | ||
expect_equal(res[["pathname"]], "/zone/1/\u6e2f\u805e") | ||
res <- ada_url_parse("http://www.m\u00fcller.de") | ||
expect_equal(res[["host"]], "www.m\u00fcller.de") | ||
res <- ada_url_parse("https://\u4e2d\u56fd\u79fb\u52a8.\u4e2d\u56fd") | ||
expect_equal(res$href[1], "https://xn--fiq02ib9d179b.xn--fiqs8s/") | ||
expect_equal(res$host[1], "\u4e2d\u56fd\u79fb\u52a8.\u4e2d\u56fd") | ||
res <- ada_url_parse("https://www.hk01.com/zone/1/\u6e2f\u805e") | ||
expect_equal(res[["pathname"]], "/zone/1/\u6e2f\u805e") | ||
res <- ada_url_parse("http://www.m\u00fcller.de") | ||
expect_equal(res[["host"]], "www.m\u00fcller.de") | ||
res <- ada_url_parse("https://\u4e2d\u56fd\u79fb\u52a8.\u4e2d\u56fd") | ||
expect_equal(res$href[1], "https://xn--fiq02ib9d179b.xn--fiqs8s/") | ||
expect_equal(res$host[1], "\u4e2d\u56fd\u79fb\u52a8.\u4e2d\u56fd") | ||
}) | ||
|
||
test_that("URLdecode optional #5", { | ||
expect_equal(ada_url_parse("https://www.google.co.jp/search?q=\u30c9\u30a4\u30c4")$search, "?q=\u30c9\u30a4\u30c4") ## default TRUE | ||
expect_equal(ada_url_parse("https://www.google.co.jp/search?q=\u30c9\u30a4\u30c4", decode = FALSE)$search, "?q=%E3%83%89%E3%82%A4%E3%83%84") | ||
expect_equal(ada_url_parse("https://www.google.co.jp/search?q=\u30c9\u30a4\u30c4")$search, "?q=\u30c9\u30a4\u30c4") ## default TRUE | ||
expect_equal(ada_url_parse("https://www.google.co.jp/search?q=\u30c9\u30a4\u30c4", decode = FALSE)$search, "?q=%E3%83%89%E3%82%A4%E3%83%84") | ||
}) | ||
|
||
test_that("multiple urls", { | ||
urls <- rep("https://user_1:[email protected]:8080/dir/../api?q=1#frag", 5) | ||
expect_equal(nrow(ada_url_parse(urls)), 5L) | ||
urls <- rep("https://user_1:[email protected]:8080/dir/../api?q=1#frag", 5) | ||
expect_equal(nrow(ada_url_parse(urls)), 5L) | ||
}) | ||
|
||
test_that("corner cases", { | ||
|
@@ -45,3 +45,12 @@ test_that("corner cases", { | |
expect_equal(x$host, c(NA_character_, NA_character_, NA_character_, NA_character_)) | ||
expect_equal(y$host, c(NA_character_, NA_character_, NA_character_, NA_character_)) | ||
}) | ||
|
||
test_that("#66", { | ||
## unicode see #67 | ||
url <- "http://xn--53-6kcainf4buoffq.xn--p1ai/\u6e2f\u805e/junior-programmer.html" | ||
res <- adaR::ada_url_parse(url) | ||
expect_equal(res$href, url) ## doesn't mess up | ||
expect_equal(res$pathname, "/\u6e2f\u805e/junior-programmer.html") | ||
expect_false(res$host == "xn--53-6kcainf4buoffq.xn--p1ai") ## puny code is converted | ||
}) |
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