Skip to content

Commit 8d58d53

Browse files
authored
fix: http error (#94)
1 parent 2125765 commit 8d58d53

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/gitingest/parse_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def _parse_url(url: str) -> dict[str, Any]:
100100
url = url.split(" ")[0]
101101
url = unquote(url) # Decode URL-encoded characters
102102

103-
if not url.startswith("https://"):
103+
if not url.startswith(("https://", "http://")):
104104
url = "https://" + url
105105

106106
# Extract domain and path

src/gitingest/tests/test_parse_query.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from gitingest.parse_query import _parse_patterns, _parse_url, parse_query
55

66

7-
def test_parse_url_valid() -> None:
7+
def test_parse_url_valid_https() -> None:
88
test_cases = [
99
"https://github.com/user/repo",
1010
"https://gitlab.com/user/repo",
@@ -17,6 +17,19 @@ def test_parse_url_valid() -> None:
1717
assert result["url"] == url
1818

1919

20+
def test_parse_url_valid_http() -> None:
21+
test_cases = [
22+
"http://github.com/user/repo",
23+
"http://gitlab.com/user/repo",
24+
"http://bitbucket.org/user/repo",
25+
]
26+
for url in test_cases:
27+
result = _parse_url(url)
28+
assert result["user_name"] == "user"
29+
assert result["repo_name"] == "repo"
30+
assert result["slug"] == "user-repo"
31+
32+
2033
def test_parse_url_invalid() -> None:
2134
url = "https://only-domain.com"
2235
with pytest.raises(ValueError, match="Invalid repository URL"):

0 commit comments

Comments
 (0)