Skip to content

Commit

Permalink
fix(parse_query): make URL handling case insensitive (cyclotruc#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipchristiansen authored Jan 8, 2025
1 parent 96bc395 commit 551d09a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/gitingest/parse_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def parse_query(
A dictionary containing the parsed query parameters, including 'max_file_size',
'ignore_patterns', and 'include_patterns'.
"""
# Normalize and clean up the source string to make it case-insensitive
source = source.lower().strip()

# Determine the parsing method based on the source type
if from_web or source.startswith("https://") or "github.com" in source:
query = _parse_url(source)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_parse_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ def test_parse_query_basic() -> None:
assert "*.txt" in result["ignore_patterns"]


def test_parse_query_mixed_case() -> None:
"""
Test `parse_query` with mixed case URLs.
"""
url = "Https://GitHub.COM/UsEr/rEpO"
result = parse_query(url, max_file_size=50, from_web=True)
assert result["user_name"] == "user"
assert result["repo_name"] == "repo"


def test_parse_query_include_pattern() -> None:
"""
Test `parse_query` with an include pattern.
Expand Down

0 comments on commit 551d09a

Please sign in to comment.