Skip to content

Preserve preferred extensions when rebuilding MIME data - #66

Closed
OskarEichler wants to merge 1 commit into
discourse:mainfrom
OskarEichler:codex/preserve-content-type-extension
Closed

OskarEichler wants to merge 1 commit into
discourse:mainfrom
OskarEichler:codex/preserve-content-type-extension

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Keep each selected MIME type’s own preferred extension when building content_type_mime.db, rather than resolving the row’s current extension back through the global filename index.

The filename lookup can select a different MIME type that shares the extension. With current mime-types-data it cross-selects 49 extension rows, produces 11 wrong preferred-extension records, and returns no type at all for .htaccess, causing rake rebuild_db to abort. This also follows the parity intent discussed in #44.

Verification

  • Ruby 4.0.6 via rbenv.
  • rake rebuild_db completes against mime-types 3.7.0 / mime-types-data 3.2026.0701.
  • All 1,073 generated content-type rows use the exact MIME type’s first extension.
  • All 2,684 generated extension/content-type rows resolve exactly through MiniMime.
  • The 11 previously cross-selected content types now use their own preferred extensions.
  • Existing core suite remains 9 runs / 22 assertions / one identical pre-existing optional parity error for reference-only extensions absent from the repository snapshot.
  • ruby -c Rakefile, targeted RuboCop, and source diff checks pass.

No generated database update or test change is included.

@ZogStriP
ZogStriP requested a review from SamSaffron September 1, 2026 15:52
@SamSaffron

Copy link
Copy Markdown
Member

fix is good but it needs a test ... cleaning up CI now

@SamSaffron SamSaffron mentioned this pull request Sep 2, 2026
SamSaffron added a commit that referenced this pull request Sep 2, 2026
Require Ruby 3.3 and refresh the bundled MIME database from
mime-types-data 3.2026.0701. Use byte offsets for Unicode-safe database
lookups, avoid duplicate lowercase misses, and preserve extension
priorities when rebuilding the database.

Update CI to cover current Ruby implementations and runners.

closes #64, #65, #66
@SamSaffron

Copy link
Copy Markdown
Member

sorry addressed in my big pr

@SamSaffron SamSaffron closed this Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants