Skip to content

Commit 747d1f8

Browse files
committed
feat: added test
1 parent acfd915 commit 747d1f8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/gitingest/parse_query.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def _parse_url(url: str) -> dict[str, Any]:
116116
_id = str(uuid.uuid4())
117117
slug = f"{user_name}-{repo_name}"
118118

119+
final_url = f"https://{domain}/{user_name}/{repo_name}" if url.startswith("https://") else f"http://{domain}/{user_name}/{repo_name}"
119120
parsed = {
120121
"user_name": user_name,
121122
"repo_name": repo_name,
@@ -124,7 +125,7 @@ def _parse_url(url: str) -> dict[str, Any]:
124125
"commit": None,
125126
"subpath": "/",
126127
"local_path": f"{TMP_BASE_PATH}/{_id}/{slug}",
127-
"url": f"https://{domain}/{user_name}/{repo_name}",
128+
"url": final_url,
128129
"slug": slug,
129130
"id": _id,
130131
}

src/gitingest/tests/test_parse_query.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def test_parse_url_valid() -> None:
99
"https://github.com/user/repo",
1010
"https://gitlab.com/user/repo",
1111
"https://bitbucket.org/user/repo",
12+
"http://github.com/user/repo",
1213
]
1314
for url in test_cases:
1415
result = _parse_url(url)

0 commit comments

Comments
 (0)