Fix composer dist URL rewriting and browse source#71
Merged
Conversation
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.
6ef197b to
b68184c
Compare
… 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.
…ead getStripPrefix, add openArchive tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).rewriteDistURLextracted this as the filename, so the archives library couldn't detect the format when browsing source. Now appends.zipwhen 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:
expandMinifiedVersionswas doing a shallow copy of inherited fields. Nested maps likedistwere shared by reference across versions. WhenrewriteDistURLmutateddist["url"]in-place, it corrupted all versions sharing that reference. 172 of 643 versions forsymfony/confighad 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.