Add automatic GitHub URL normalization to raw.githubusercontent.com#14
Merged
Add automatic GitHub URL normalization to raw.githubusercontent.com#14
Conversation
Implements GitHub Issue #3: Auto-fix GitHub URLs during sync operations. - Convert GitHub URLs from /blob/ and /raw/ formats to raw.githubusercontent.com - Apply to all file URLs in modinfo and toolinfo files (files hash and fileURL) - Apply to imageURL and readmeURL fields - Add warnings to alert users when URLs are auto-fixed - Add comprehensive test coverage (21 new test cases) - Update README with note about automatic URL conversion This ensures compatibility with GitHub's raw file hosting on raw.githubusercontent.com and prevents download failures from incorrect URL formats. Version 2.5.0 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements automatic GitHub URL normalization to convert /blob/ and /raw/ URL formats to the correct raw.githubusercontent.com format for direct file downloads. This addresses GitHub Issue #3 and ensures compatibility with GitHub's raw file hosting infrastructure.
Changes:
- Added regex-based URL normalization in the
Baseinfoclass with warning system to alert users - Extended normalization to
Modinfo(files hash) andToolinfo(fileURL) subclasses - Added 21 comprehensive test cases covering various URL formats and edge cases
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| lib/icarus/mod/tools/baseinfo.rb | Core normalization logic with GITHUB_BLOB_RAW_URL_PATTERN regex and normalize_github_url method |
| lib/icarus/mod/tools/modinfo.rb | Override to normalize all URLs in the files hash with guard clause |
| lib/icarus/mod/tools/toolinfo.rb | Override to normalize the fileURL field |
| spec/icarus/mod/tools/baseinfo_spec.rb | 103 lines of tests for normalize_github_url covering blob/raw/edge cases |
| spec/icarus/mod/tools/modinfo_spec.rb | 41 lines of tests for files hash normalization and nil safety |
| spec/icarus/mod/tools/toolinfo_spec.rb | 31 lines of tests for fileURL normalization |
| lib/icarus/mod/version.rb | Version bump from 2.4.1 to 2.5.0 |
| CHANGELOG.md | Added v2.5.0 entry documenting the new feature |
| README.md | Added note about automatic URL conversion behavior |
Adds guard to prevent FrozenError when data comes from Firestore. URL normalization should only happen when reading from source files (modinfo.json/toolinfo.json), not when loading already-processed data from Firestore. Fixes runtime error: can't modify frozen Hash (FrozenError) in normalize_github_urls_in_data
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.
Summary
Implements GitHub Issue #3: Auto-fix GitHub URLs during sync operations.
This PR adds automatic conversion of GitHub URLs from
/blob/and/raw/formats to the correctraw.githubusercontent.comformat. This ensures compatibility with GitHub's current raw file hosting and prevents download failures from incorrect URL formats.Changes
Baseinfoclass to detect and convert GitHub URLsModinfoto handle thefileshash containing multiple file typesToolinfoto handle thefileURLfieldFiles Modified
lib/icarus/mod/tools/baseinfo.rb- Core normalization logic with regex patternlib/icarus/mod/tools/modinfo.rb- Override for files hash normalizationlib/icarus/mod/tools/toolinfo.rb- Override for fileURL normalizationspec/icarus/mod/tools/baseinfo_spec.rb- +103 lines of test coveragespec/icarus/mod/tools/modinfo_spec.rb- +41 lines of test coveragespec/icarus/mod/tools/toolinfo_spec.rb- +31 lines of test coveragelib/icarus/mod/version.rb- Version bump to 2.5.0CHANGELOG.md- Added v2.5.0 entryREADME.md- Added note about automatic URL conversionURL Transformation Examples
https://github.com/owner/repo/blob/main/file.zip→https://raw.githubusercontent.com/owner/repo/main/file.ziphttps://github.com/owner/repo/raw/main/file.zip→https://raw.githubusercontent.com/owner/repo/main/file.zipTest Results
All 324 tests passing (21 new tests added).
Version
2.5.0 (minor version bump - new feature)
Closes #3
🤖 Generated with Claude Code