mirror of
https://github.com/github/spec-kit.git
synced 2026-07-09 16:35:58 +08:00
Prefer final_url over original URL for archive format detection in download paths
This commit is contained in:
committed by
GitHub
parent
a8320d9b61
commit
a69d427e03
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user