Skip to content

Commit 18b43bf

Browse files
add compressed trie example
1 parent 9ee5fe3 commit 18b43bf

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,38 @@ For example, it extracts the `com` TLD, `maps` subdomain, and `google` domain fr
2525

2626
Splitting on "." and taking the last element only works for simple TLDs like `.com`, but not more complex ones like `oseto.nagasaki.jp`.
2727

28+
### Compressed trie example
29+
30+
Valid TLDs from the [Mozilla Public Suffix List](http://www.publicsuffix.org) are appended to the compressed trie in reverse-order.
31+
32+
```sh
33+
Given the following TLDs
34+
au
35+
nsw.edu.au
36+
com.ac
37+
edu.ac
38+
gov.ac
39+
40+
and the example URI host `example.nsw.edu.au`
41+
42+
The compressed trie will be structured as follows:
43+
44+
START
45+
╠═ au 🚩 ✅
46+
║ ╚═ edu ✅
47+
║ ╚═ nsw 🚩 ✅
48+
╚═ ac 🚩
49+
╠═ com 🚩
50+
╠═ edu 🚩
51+
╚═ gov 🚩
52+
53+
=== Symbol meanings ===
54+
🚩 : path to this node is a valid TLD
55+
: path to this node found in example URI host `example.nsw.edu.au`
56+
```
57+
58+
The URI host subcomponents are parsed from right-to-left until no more matching nodes can be found. In this example, the path of matching nodes are `au -> edu -> nsw`. Reversing the nodes gives the extracted TLD `nsw.edu.au`.
59+
2860
## Installation
2961

3062
```sh

0 commit comments

Comments
 (0)