Skip to content

Commit 26aa23b

Browse files
authored
[FIX] IndexError when parsing incomplete urls without a host part (#7)
1 parent 5c2b361 commit 26aa23b

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/mdurl/_parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def parse(self, url: str, slashes_denote_host: bool) -> "MutableURL":
202202
if host_end == -1:
203203
host_end = len(rest)
204204

205-
if rest[host_end - 1] == ":":
205+
if host_end > 0 and rest[host_end - 1] == ":":
206206
host_end -= 1
207207
host = rest[:host_end]
208208
rest = rest[host_end:]

tests/fixtures/url.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,4 +601,10 @@
601601
"pathname": "/fooA100%mBr",
602602
"slashes": True,
603603
},
604+
#
605+
"http://": {
606+
"protocol": "http:",
607+
"hostname": "",
608+
"slashes": True,
609+
}
604610
}

0 commit comments

Comments
 (0)