mirror of
https://github.com/Dasemu/x-space-downloader.git
synced 2026-11-28 00:06:50 +00:00
feat: add validator error cases and twitter.com support
Added comprehensive test coverage for URL validation: - Test for invalid URL formats (missing /i/, missing space ID, malformed URLs) - Test for twitter.com domain support (in addition to x.com) Updated validator implementation: - Extended regex pattern to accept both x.com and twitter.com domains - Updated group capture index to account for domain alternation All validator tests passing (3/3). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
52ee05e009
commit
21b3dfd8b2
2 files changed
+29
-3
No files matched your search
+3
-3
@@ -12,12 +12,12 @@ def validate_space_url(url: str) -> Tuple[bool, Optional[str], Optional[str]]:
|
||||
Returns:
|
||||
Tuple of (is_valid, space_id, error_message)
|
||||
"""
|
||||
# Pattern for X Space URLs
|
||||
pattern = r"https://x\.com/i/spaces/([a-zA-Z0-9]+)"
|
||||
# Pattern for X Space URLs (supports both x.com and twitter.com)
|
||||
pattern = r"https://(x|twitter)\.com/i/spaces/([a-zA-Z0-9]+)"
|
||||
match = re.match(pattern, url)
|
||||
|
||||
if not match:
|
||||
return False, None, "Invalid URL format. Expected: https://x.com/i/spaces/{SPACE_ID}"
|
||||
|
||||
space_id = match.group(1)
|
||||
space_id = match.group(2) # Changed from group(1) to group(2)
|
||||
return True, space_id, None
|
||||
Reference in new issue
Block a user