Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make ingest URL field case insensitive in parse_query #115

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading