Repository: cyclotruc/gitingest

Issue:
Git Ingest request fails on web if the input repo url starts with "http://" instead of "https://"
I think it might be related to `_parse_url` in `parse_query.py` explicitly checking for `"https://"`. Was this intended?
![Screenshot 2024-12-31 190644](https://github.com/user-attachments/assets/621649c8-a942-4478-904f-1287305d5a09)

Hints from issue comments:
@cyclotruc: You are right it should in fact not change anything on gitingest side because the `https` / `http` doesn't change anything to the clone. This will be fixed!
@joydeep049: I am looking into this!


Solution patch:
diff --git a/src/gitingest/parse_query.py b/src/gitingest/parse_query.py
index 18a78e9..859cafb 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


Test patch:
diff --git a/src/gitingest/tests/test_parse_query.py b/src/gitingest/tests/test_parse_query.py
index 8ce3ff0..b6b2038 100644
--- a/src/gitingest/tests/test_parse_query.py
+++ b/src/gitingest/tests/test_parse_query.py
@@ -4,7 +4,7 @@ from gitingest.ignore_patterns import DEFAULT_IGNORE_PATTERNS
 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"):