-
Notifications
You must be signed in to change notification settings - Fork 3
test: add url utility for bot review #95
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| def parse_url(url): | ||
| parts = url.split("://") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [HIGH] Bug / Robustness: Splitting the URL with Suggested fix: from urllib.parse import urlparse
def parse_url(url: str) -> tuple[str, str] | None:
try:
parsed = urlparse(url)
if not parsed.scheme or not parsed.netloc:
return None
return parsed.scheme, parsed.netloc + parsed.path
except Exception:
return None |
||
| if len(parts) != 2: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [HIGH] Bug: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 [MEDIUM] ValueError: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [HIGH] Bug: |
||
| return None | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 [MEDIUM] TypeError: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 [MEDIUM] Style / Error handling: Returning Suggested fix: Replace |
||
| return parts[0], parts[1] | ||
|
|
||
|
|
||
| def is_secure(url): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 [MEDIUM] Bug / Security: Suggested fix: def is_secure(url: str) -> bool:
return url.strip().lower().startswith('https://') |
||
| return url.startswith("https://") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 [LOW] Style: The security check only considers 'https' as secure. Consider supporting other secure protocols like 'sftp' or 'ssh' as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 [LOW] Insecurity: |
||
|
|
||
|
|
||
| def get_path(url): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 [CRITICAL] Bug / Crash risk: Suggested fix: Use from urllib.parse import urlparse
def get_path(url: str) -> str:
parsed = urlparse(url)
return parsed.path.lstrip('/') |
||
| return url.split("/", 3)[3] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 [MEDIUM] Bug: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [HIGH] IndexError: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [HIGH] IndexError: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 [MEDIUM] IndexError: |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 [LOW] Style: The module lacks docstrings and type hints, which hurts readability and static analysis. Add a module docstring and annotate all functions, e.g.,
def parse_url(url: str) -> tuple[str, str] | None:.