Skip to content

Commit

Permalink
update of public_suffix part
Browse files Browse the repository at this point in the history
  • Loading branch information
schochastics committed Sep 26, 2023
1 parent b6398fa commit 20f0b6a
Showing 1 changed file with 38 additions and 36 deletions.
74 changes: 38 additions & 36 deletions vignettes/adaR.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ vignette: >

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
collapse = TRUE,
comment = "#>"
)
```

Expand Down Expand Up @@ -106,35 +106,35 @@ ada_url_parse("https://user_1:[email protected]:8080/dir/../api?q=1#frag")
The function can deal with punycode and percent encoding and does generally handle all types of edge cases well.
```{r ada_corner}
corner_cases <- c(
"https://example.com:8080", "http://user:[email protected]",
"http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:8080", "https://example.com/path/to/resource?query=value&another=thing#fragment",
"http://sub.sub.example.com", "ftp://files.example.com:2121/download/file.txt",
"http://example.com/path with spaces/and&special=characters?",
"https://user:pa%[email protected]/path", "http://example.com/..//a/b/../c/./d.html",
"https://example.com:8080/over/under?query=param#and-a-fragment",
"http://192.168.0.1/path/to/resource", "http://3com.com/path/to/resource",
"http://example.com/%7Eusername/", "https://example.com/a?query=value&query=value2",
"https://example.com/a/b/c/..", "ws://websocket.example.com:9000/chat",
"https://example.com:65535/edge-case-port", "file:///home/user/file.txt",
"http://example.com/a/b/c/%2F%2F", "http://example.com/a/../a/../a/../a/",
"https://example.com/./././a/", "http://example.com:8080/a;b?c=d#e",
"http://@example.com", "http://example.com/@test", "http://example.com/@@@/a/b",
"https://example.com:0/", "http://example.com/%25path%20with%20encoded%20chars",
"https://example.com/path?query=%26%3D%3F%23", "http://example.com:8080/?query=value#fragment#fragment2",
"https://example.xn--80akhbyknj4f/path/to/resource", "https://example.co.uk/path/to/resource",
"http://username:pass%[email protected]", "ftp://downloads.example.edu:3030/files/archive.zip",
"https://example.com:8080/this/is/a/deeply/nested/path/to/a/resource",
"http://another-example.com/..//test/./demo.html", "https://sub2.sub1.example.org:5000/login?user=test#section2",
"ws://chat.example.biz:5050/livechat", "http://192.168.1.100/a/b/c/d",
"https://secure.example.shop/cart?item=123&quantity=5", "http://example.travel/%60%21%40%23%24%25%5E%26*()",
"https://example.museum/path/to/artifact?search=ancient", "ftp://secure-files.example.co:4040/files/document.docx",
"https://test.example.aero/booking?flight=abc123", "http://example.asia/%E2%82%AC%E2%82%AC/path",
"http://subdomain.example.tel/contact?name=john", "ws://game-server.example.jobs:2020/match?id=xyz",
"http://example.mobi/path/with/mobile/content", "https://example.name/family/tree?name=smith",
"http://192.168.2.2/path?query1=value1&query2=value2", "http://example.pro/professional/services",
"https://example.info/information/page", "http://example.int/internal/systems/login",
"https://example.post/postal/services", "http://example.xxx/age/verification",
"https://example.xxx/another/edge/case/path?with=query#and-fragment"
"https://example.com:8080", "http://user:[email protected]",
"http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:8080", "https://example.com/path/to/resource?query=value&another=thing#fragment",
"http://sub.sub.example.com", "ftp://files.example.com:2121/download/file.txt",
"http://example.com/path with spaces/and&special=characters?",
"https://user:pa%[email protected]/path", "http://example.com/..//a/b/../c/./d.html",
"https://example.com:8080/over/under?query=param#and-a-fragment",
"http://192.168.0.1/path/to/resource", "http://3com.com/path/to/resource",
"http://example.com/%7Eusername/", "https://example.com/a?query=value&query=value2",
"https://example.com/a/b/c/..", "ws://websocket.example.com:9000/chat",
"https://example.com:65535/edge-case-port", "file:///home/user/file.txt",
"http://example.com/a/b/c/%2F%2F", "http://example.com/a/../a/../a/../a/",
"https://example.com/./././a/", "http://example.com:8080/a;b?c=d#e",
"http://@example.com", "http://example.com/@test", "http://example.com/@@@/a/b",
"https://example.com:0/", "http://example.com/%25path%20with%20encoded%20chars",
"https://example.com/path?query=%26%3D%3F%23", "http://example.com:8080/?query=value#fragment#fragment2",
"https://example.xn--80akhbyknj4f/path/to/resource", "https://example.co.uk/path/to/resource",
"http://username:pass%[email protected]", "ftp://downloads.example.edu:3030/files/archive.zip",
"https://example.com:8080/this/is/a/deeply/nested/path/to/a/resource",
"http://another-example.com/..//test/./demo.html", "https://sub2.sub1.example.org:5000/login?user=test#section2",
"ws://chat.example.biz:5050/livechat", "http://192.168.1.100/a/b/c/d",
"https://secure.example.shop/cart?item=123&quantity=5", "http://example.travel/%60%21%40%23%24%25%5E%26*()",
"https://example.museum/path/to/artifact?search=ancient", "ftp://secure-files.example.co:4040/files/document.docx",
"https://test.example.aero/booking?flight=abc123", "http://example.asia/%E2%82%AC%E2%82%AC/path",
"http://subdomain.example.tel/contact?name=john", "ws://game-server.example.jobs:2020/match?id=xyz",
"http://example.mobi/path/with/mobile/content", "https://example.name/family/tree?name=smith",
"http://192.168.2.2/path?query1=value1&query2=value2", "http://example.pro/professional/services",
"https://example.info/information/page", "http://example.int/internal/systems/login",
"https://example.post/postal/services", "http://example.xxx/age/verification",
"https://example.xxx/another/edge/case/path?with=query#and-fragment"
)
df <- ada_url_parse(corner_cases)
Expand All @@ -153,14 +153,16 @@ ada_has_search(corner_cases)

## Public suffic extraction

The package also implements a public suffix extractor `public_suffix()`, based on a
lookup of the [Public Suffix List](https://publicsuffix.org/) (*The list also includes private top level domains, which we excluded from this function*).
The package also implements a public suffix extractor public_suffix(), based on a lookup of the [Public Suffix List](https://publicsuffix.org/).
Note that from this list, we only include registry suffixes (e.g., com, co.uk), which are those controlled by a domain name registry and governed by ICANN.
We do not include "private" suffixes (e.g., blogspot.com) that allow people to register subdomains. Hence, we use the term domain in the sense of "top domain under a registry suffix".
See <https://github.com/google/guava/wiki/InternetDomainNameExplained> for more details.

```{r public_suffix}
urls <- c(
"https://subsub.sub.domain.co.uk",
"https://domain.api.gov.uk",
"https://thisisnotpart.butthisispartoftheps.kawasaki.jp"
"https://subsub.sub.domain.co.uk",
"https://domain.api.gov.uk",
"https://thisisnotpart.butthisispartoftheps.kawasaki.jp"
)
public_suffix(urls)
```
Expand Down

0 comments on commit 20f0b6a

Please sign in to comment.