Skip to content

Fix composer dist URL rewriting and browse source#71

Merged
andrew merged 4 commits intomainfrom
fix-composer-dist-urls
Apr 6, 2026
Merged

Fix composer dist URL rewriting and browse source#71
andrew merged 4 commits intomainfrom
fix-composer-dist-urls

Conversation

@andrew
Copy link
Copy Markdown
Contributor

@andrew andrew commented Apr 6, 2026

Fixes two bugs reported in #61 and improves browse source for archives with wrapper directories.

Missing .zip extension: GitHub zipball URLs end with a bare commit hash (e.g. .../zipball/abc123). rewriteDistURL extracted this as the filename, so the archives library couldn't detect the format when browsing source. Now appends .zip when the filename has no extension and the dist type is zip. archiveFilename() in browse.go also handles existing cached artifacts with extensionless filenames.

Shared map references in minified expansion: expandMinifiedVersions was doing a shallow copy of inherited fields. Nested maps like dist were shared by reference across versions. When rewriteDistURL mutated dist["url"] in-place, it corrupted all versions sharing that reference. 172 of 643 versions for symfony/config had wrong dist URLs. Now deep copies inherited values before merging.

Auto-strip single root directory in browse source: GitHub zipballs wrap all files in a repo-hash/ directory, which showed up as a confusing extra folder in browse source. Now auto-detects when all files share a single top-level directory and strips it. This works generically for any ecosystem, not just composer.

andrew added 2 commits April 6, 2026 17:07
GitHub zipball URLs produce filenames without .zip extension, breaking
browse source. Minified version expansion shares nested map references,
causing dist URL corruption when versions inherit unchanged dist fields.
…ilenames

GitHub zipball URLs end in a bare commit hash with no file extension.
rewriteDistURL now appends .zip when the filename has no extension and
the dist type is zip. expandMinifiedVersions deep copies inherited
values so in-place URL rewriting no longer corrupts shared references.
browse.go infers .zip for extensionless filenames so existing cached
artifacts can still be opened.
@andrew andrew force-pushed the fix-composer-dist-urls branch from 6ef197b to b68184c Compare April 6, 2026 16:07
andrew added 2 commits April 6, 2026 17:14
… archives

GitHub zipballs wrap all files in a repo-hash/ directory. Instead of
hardcoding prefixes per ecosystem, open the archive once to check if all
files share a single root directory and strip it automatically. The npm
package/ prefix is still handled as a special case.
@andrew andrew merged commit e1d2331 into main Apr 6, 2026
5 checks passed
@andrew andrew deleted the fix-composer-dist-urls branch April 6, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant