|
4 | 4 | from rfc3986.uri import URIReference |
5 | 5 | from rfc3986.normalizers import ( |
6 | 6 | normalize_scheme, normalize_percent_characters, |
7 | | - remove_dot_segments, encode_component, |
| 7 | + remove_dot_segments, encode_component, normalize_host |
8 | 8 | ) |
9 | 9 |
|
10 | 10 |
|
@@ -93,3 +93,20 @@ def test_fragment_normalization(): |
93 | 93 | ) |
94 | 94 | def test_detect_percent_encoded_component(component, encoded_component): |
95 | 95 | assert encode_component(component, 'utf-8') == encoded_component |
| 96 | + |
| 97 | + |
| 98 | +@pytest.mark.parametrize( |
| 99 | + ["host", "normalized_host"], |
| 100 | + [ |
| 101 | + ('LOCALHOST', 'localhost'), |
| 102 | + ('[::1%eth0]', '[::1%25eth0]'), |
| 103 | + ('[::1%25]', '[::1%2525]'), |
| 104 | + ('[::1%%25]', '[::1%25%25]'), |
| 105 | + ('[::1%25%25]', '[::1%25%25]'), |
| 106 | + ('[::Af%Ff]', '[::af%25Ff]'), |
| 107 | + ('[::Af%%Ff]', '[::af%25%Ff]'), |
| 108 | + ('[::Af%25Ff]', '[::af%25Ff]'), |
| 109 | + ] |
| 110 | +) |
| 111 | +def test_normalize_host(host, normalized_host): |
| 112 | + assert normalize_host(host) == normalized_host |
0 commit comments