Skip to content

Commit 7bfe993

Browse files
lemireanonrig
authored andcommitted
Documenting what the library does.
1 parent 869605d commit 7bfe993

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,32 @@ ada-url
55
This is ``ada_url``, a Python library for parsing and joining URLs.
66

77

8+
WHATWG URL compliance
9+
---------------------
10+
11+
Unlike the standard library's ``urllib.parse`` module, this library is compliant with the WHATWG URL spec.
12+
13+
.. code-block:: python
14+
15+
urlstring = "https://www.GOoglé.com/./path/../path2/"
16+
17+
import ada_url
18+
19+
# prints www.xn--googl-fsa.com,
20+
# the correctly parsed domain name according to WHATWG
21+
print(ada_url.URL(urlstring).hostname)
22+
# prints /path2/
23+
# the correctly parsed pathname according to WHATWG
24+
print(ada_url.URL(urlstring).pathname)
25+
26+
import urllib
27+
28+
#prints www.googlé.com
29+
print(urllib.parse.urlparse(urlstring).hostname)
30+
#prints /./path/../path2/
31+
print(urllib.parse.urlparse(urlstring).path)
32+
33+
834
Examples
935
--------
1036

0 commit comments

Comments
 (0)