Skip to content

Commit 1957c2b

Browse files
authored
Merge pull request #96 from handrews/empty
Match empty path without using line begin/end
2 parents 3875725 + 2de71cd commit 1957c2b

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/rfc3986/abnf_regexp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
}
151151

152152
# Path types taken from Section 3.3 (linked above)
153-
PATH_EMPTY = "^$"
153+
PATH_EMPTY = "(?:)"
154154
PATH_ROOTLESS = "%(segment-nz)s(/%(segment)s)*" % segments
155155
PATH_NOSCHEME = "%(segment-nz-nc)s(/%(segment)s)*" % segments
156156
PATH_ABSOLUTE = "/(%s)?" % PATH_ROOTLESS

tests/conftest.py

+10
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@ def uri_with_everything(request):
106106
)
107107

108108

109+
@pytest.fixture
110+
def uri_without_authority_with_empty_path():
111+
return "about:"
112+
113+
114+
@pytest.fixture
115+
def uri_without_authority_with_query_only():
116+
return "about:?foo=bar"
117+
118+
109119
@pytest.fixture(params=valid_hosts)
110120
def relative_uri(request):
111121
return "//%s" % request.param

tests/test_uri.py

+13
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,19 @@ def test_absolute_paths_are_not_absolute_uris(self, absolute_path_uri):
269269
uri = URIReference.from_string(absolute_path_uri)
270270
assert uri.is_absolute() is False
271271

272+
def test_uris_with_no_authority_with_empty_path_are_absolute(
273+
self,
274+
uri_without_authority_with_empty_path,
275+
):
276+
uri = URIReference.from_string(uri_without_authority_with_empty_path)
277+
278+
def test_uris_with_no_authority_with_query_only_are_absolute(
279+
self,
280+
uri_without_authority_with_query_only,
281+
):
282+
uri = URIReference.from_string(uri_without_authority_with_query_only)
283+
assert uri.is_absolute() is True
284+
272285

273286
# @pytest.fixture(params=[
274287
# basic_uri, basic_uri_with_port, basic_uri_with_path,

0 commit comments

Comments
 (0)