Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/hyperlink/_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ def _encode_path_parts(
for part in text_parts
]
else:
encoded_parts = [_encode_schemeless_path_part(text_parts[0])]
encoded_parts = [
_encode_schemeless_path_part(text_parts[0], maximal=maximal)
]
encoded_parts.extend(
[
_encode_path_part(part, maximal=maximal) if part else part
Expand Down
10 changes: 10 additions & 0 deletions src/hyperlink/test/test_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,16 @@ def test_schemeless_path(self):
u6 = URL.from_text(u5.to_text()).to_uri()
assert u5 == u6 # colons stay decoded bc they're not in the first seg

def test_schemeless_iri_path(self):
# type: () -> None
"""Relative IRI paths preserve Unicode while escaping delimiters."""
url = URL(path=("café:menu", "next"))
iri_text = "café%3Amenu/next"
uri_text = "caf%C3%A9%3Amenu/next"
assert url.to_text() == iri_text
assert url.to_uri().to_text() == uri_text
assert URL.from_text(uri_text).to_iri().to_text() == iri_text

def test_emoji_domain(self):
# type: () -> None
"See issue #7, affecting only narrow builds (2.6-3.3)"
Expand Down