Skip to content

Commit 2c6f4f0

Browse files
committed
Add test cases specifically for % detection
1 parent c37a1c6 commit 2c6f4f0

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/test_normalizers.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
from rfc3986.uri import URIReference
55
from rfc3986.normalizers import (
6-
normalize_scheme, normalize_percent_characters, remove_dot_segments
6+
normalize_scheme, normalize_percent_characters,
7+
remove_dot_segments, encode_component,
78
)
89

910

@@ -76,3 +77,19 @@ def test_fragment_normalization():
7677
uri = URIReference(
7778
None, 'example.com', None, None, 'fiz%DF').normalize()
7879
assert uri.fragment == 'fiz%DF'
80+
81+
82+
@pytest.mark.parametrize(
83+
["component", "encoded_component"],
84+
[
85+
('/%', '/%25'),
86+
('/%a', '/%25a'),
87+
('/%ag', '/%25ag'),
88+
('/%af', '/%af'),
89+
('/%20/%', '/%2520/%25'),
90+
('/%20%25', '/%20%25'),
91+
('/%21%22%23%ah%12%ff', '/%2521%2522%2523%25ah%2512%25ff'),
92+
]
93+
)
94+
def test_detect_percent_encoded_component(component, encoded_component):
95+
assert encode_component(component, 'utf-8') == encoded_component

0 commit comments

Comments
 (0)