diff --git a/src/gitingest/parse_query.py b/src/gitingest/parse_query.py index 18a78e9a..859cafb2 100644 --- a/src/gitingest/parse_query.py +++ b/src/gitingest/parse_query.py @@ -100,7 +100,7 @@ def _parse_url(url: str) -> dict[str, Any]: url = url.split(" ")[0] url = unquote(url) # Decode URL-encoded characters - if not url.startswith("https://"): + if not url.startswith(("https://", "http://")): url = "https://" + url # Extract domain and path diff --git a/src/gitingest/tests/test_parse_query.py b/src/gitingest/tests/test_parse_query.py index 8ce3ff00..b6b20389 100644 --- a/src/gitingest/tests/test_parse_query.py +++ b/src/gitingest/tests/test_parse_query.py @@ -4,7 +4,7 @@ from gitingest.parse_query import _parse_patterns, _parse_url, parse_query -def test_parse_url_valid() -> None: +def test_parse_url_valid_https() -> None: test_cases = [ "https://github.com/user/repo", "https://gitlab.com/user/repo", @@ -17,6 +17,19 @@ def test_parse_url_valid() -> None: assert result["url"] == url +def test_parse_url_valid_http() -> None: + test_cases = [ + "http://github.com/user/repo", + "http://gitlab.com/user/repo", + "http://bitbucket.org/user/repo", + ] + for url in test_cases: + result = _parse_url(url) + assert result["user_name"] == "user" + assert result["repo_name"] == "repo" + assert result["slug"] == "user-repo" + + def test_parse_url_invalid() -> None: url = "https://only-domain.com" with pytest.raises(ValueError, match="Invalid repository URL"):