Prefer final_url over original URL for archive format detection in download paths

This commit is contained in:
copilot-swe-agent[bot]
2026-05-12 13:19:50 +00:00
committed by GitHub
parent a8320d9b61
commit a69d427e03
3 changed files with 31 additions and 20 deletions

View File

@@ -2156,17 +2156,19 @@ class ExtensionCatalog:
version = ext_info.get("version", "unknown")
# Detect archive format from URL; resolve via Content-Type when needed.
# `final_url` may differ from `download_url` if the server redirects.
archive_fmt = detect_archive_format(download_url)
# Download the archive
# Download the archive. Determine the archive format from the
# post-redirect URL first (with Content-Type fallback); only use the
# original `download_url` as a last hint if the final URL gives no
# signal.
final_url = download_url
archive_fmt = ""
try:
with self._open_url(download_url, timeout=60) as response:
final_url = response.geturl()
content_type = response.headers.get("Content-Type", "")
archive_fmt = detect_archive_format(final_url, content_type)
if not archive_fmt:
content_type = response.headers.get("Content-Type", "")
archive_fmt = detect_archive_format(final_url, content_type)
archive_fmt = detect_archive_format(download_url)
archive_data = response.read()
except urllib.error.URLError as e: