Skip to content
Open
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
10 changes: 9 additions & 1 deletion scripts/render_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import re
import subprocess
from urllib.parse import urlparse

OUTPUT = 'README.md'

Expand Down Expand Up @@ -156,7 +157,14 @@ def standalone_repl(m):
img_url = im.group(1).strip() if im else ''
img_parsed = extract_owner_repo_from_url(img_url) if img_url else None
# If it's a GitHub actions badge for this repo, link to the workflow page
if img_url and 'github.com' in img_url and '/actions/workflows/' in img_url and img_parsed == (owner.lower(), repo.lower()):
if img_url:
parsed = urlparse(img_url)
host = (parsed.hostname or '').lower()
path = parsed.path or ''
else:
host = ''
path = ''
Comment on lines +160 to +166
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The URL parsing logic can be simplified. The if-else structure (lines 160-166) is redundant because line 167 already checks "if img_url". When img_url is empty, parsing it would still work safely and result in empty host and path values, causing the condition on line 167 to fail naturally. Consider simplifying to: parsed = urlparse(img_url) if img_url else urlparse(''); host = (parsed.hostname or '').lower(); path = parsed.path or ''. This reduces nesting and makes the code more readable.

Suggested change
if img_url:
parsed = urlparse(img_url)
host = (parsed.hostname or '').lower()
path = parsed.path or ''
else:
host = ''
path = ''
parsed = urlparse(img_url) if img_url else urlparse('')
host = (parsed.hostname or '').lower()
path = parsed.path or ''

Copilot uses AI. Check for mistakes.
Comment on lines +160 to +166
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable host is not used.

Suggested change
if img_url:
parsed = urlparse(img_url)
host = (parsed.hostname or '').lower()
path = parsed.path or ''
else:
host = ''
path = ''
host = ''
path = ''
if img_url:
parsed = urlparse(img_url)
host = (parsed.hostname or '').lower()
path = parsed.path or ''

Copilot uses AI. Check for mistakes.
Comment on lines +160 to +166
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable path is not used.

Suggested change
if img_url:
parsed = urlparse(img_url)
host = (parsed.hostname or '').lower()
path = parsed.path or ''
else:
host = ''
path = ''
host = ''
path = ''
if img_url:
parsed = urlparse(img_url)
host = (parsed.hostname or '').lower()
path = parsed.path or ''

Copilot uses AI. Check for mistakes.
if img_url and host == 'github.com' and '/actions/workflows/' in path and img_parsed == (owner.lower(), repo.lower()):
mb = re.search(r'/actions/workflows/(?P<wf>[^/]+)(?:/badge\.svg(?:\?.*)?)?$', img_url)
wf_basename = mb.group('wf') if mb else None
alt_name = os.path.splitext(wf_basename)[0] if wf_basename else None
Expand Down
Loading