Skip to content

Add automatic GitHub URL normalization to raw.githubusercontent.com#14

Merged
dyoung522 merged 3 commits intomainfrom
feature/auto-fix-github-urls
Jan 12, 2026
Merged

Add automatic GitHub URL normalization to raw.githubusercontent.com#14
dyoung522 merged 3 commits intomainfrom
feature/auto-fix-github-urls

Conversation

@dyoung522
Copy link
Contributor

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 correct raw.githubusercontent.com format. This ensures compatibility with GitHub's current raw file hosting and prevents download failures from incorrect URL formats.

Changes

  • URL Normalization Logic: Added regex-based pattern matching in Baseinfo class to detect and convert GitHub URLs
  • Modinfo Support: Override in Modinfo to handle the files hash containing multiple file types
  • Toolinfo Support: Override in Toolinfo to handle the fileURL field
  • Warning System: Warnings added to alert users when URLs are auto-fixed so they can update their source files
  • Comprehensive Tests: Added 21 new test cases covering various URL formats and edge cases

Files Modified

  • lib/icarus/mod/tools/baseinfo.rb - Core normalization logic with regex pattern
  • lib/icarus/mod/tools/modinfo.rb - Override for files hash normalization
  • lib/icarus/mod/tools/toolinfo.rb - Override for fileURL normalization
  • spec/icarus/mod/tools/baseinfo_spec.rb - +103 lines of test coverage
  • spec/icarus/mod/tools/modinfo_spec.rb - +41 lines of test coverage
  • spec/icarus/mod/tools/toolinfo_spec.rb - +31 lines of test coverage
  • lib/icarus/mod/version.rb - Version bump to 2.5.0
  • CHANGELOG.md - Added v2.5.0 entry
  • README.md - Added note about automatic URL conversion

URL Transformation Examples

  • https://github.com/owner/repo/blob/main/file.ziphttps://raw.githubusercontent.com/owner/repo/main/file.zip
  • https://github.com/owner/repo/raw/main/file.ziphttps://raw.githubusercontent.com/owner/repo/main/file.zip

Test Results

All 324 tests passing (21 new tests added).

Version

2.5.0 (minor version bump - new feature)

Closes #3

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings January 12, 2026 03:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Baseinfo class with warning system to alert users
  • Extended normalization to Modinfo (files hash) and Toolinfo (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
@dyoung522 dyoung522 merged commit 0be6342 into main Jan 12, 2026
1 check passed
@dyoung522 dyoung522 deleted the feature/auto-fix-github-urls branch January 12, 2026 03:35
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.

Fix direct-download links (blob -> raw) when hosted on Github

2 participants