diff --git a/src/mdurl/_parse.py b/src/mdurl/_parse.py index 9eb57a7..ffeeac7 100644 --- a/src/mdurl/_parse.py +++ b/src/mdurl/_parse.py @@ -202,7 +202,7 @@ def parse(self, url: str, slashes_denote_host: bool) -> "MutableURL": if host_end == -1: host_end = len(rest) - if rest[host_end - 1] == ":": + if host_end > 0 and rest[host_end - 1] == ":": host_end -= 1 host = rest[:host_end] rest = rest[host_end:] diff --git a/tests/fixtures/url.py b/tests/fixtures/url.py index 7dc311c..0bae987 100644 --- a/tests/fixtures/url.py +++ b/tests/fixtures/url.py @@ -601,4 +601,10 @@ "pathname": "/fooA100%mBr", "slashes": True, }, + # + "http://": { + "protocol": "http:", + "hostname": "", + "slashes": True, + } }