File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 5
5
This is ``ada_url ``, a Python library for parsing and joining URLs.
6
6
7
7
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
+
8
34
Examples
9
35
--------
10
36
You can’t perform that action at this time.
0 commit comments