fix: Fixed default charset behavior for various non-text/plain content types#111
Merged
dazuma merged 1 commit intocloudevents:mainfrom Jan 15, 2026
Merged
Conversation
4ba2705 to
acdd353
Compare
acdd353 to
ce23938
Compare
There was a problem hiding this comment.
Pull request overview
This pull request fixes the default charset behavior for various content types. Previously, us-ascii was the default charset for all content types without an explicit charset parameter. The fix introduces smarter defaults: text/plain defaults to us-ascii, text-based and JSON-based content types default to utf-8, and binary content types (like images) have no default charset.
Changes:
- Updated
ContentTypeclass to intelligently select default charsets based on media type and subtype - Modified test fixtures to reflect the new behavior with proper JSON objects containing UTF-8 characters
- Added comprehensive test coverage for the new charset defaulting logic
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/cloud_events/content_type.rb | Implements intelligent charset selection logic via choose_default_charset method; changes initialization to set all instance variables to nil initially and apply defaults in ensure block |
| test/test_content_type.rb | Adds test cases for different content types and their expected charset defaults (text/plain → us-ascii, application/json → utf-8, text/html → utf-8, image/png → nil) |
| test/test_http_binding.rb | Updates test fixtures: changes JSON test data from simple string to object with UTF-8 characters, removes charset from JSON content type string, converts all let : syntax to let(:) for consistency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…t types Signed-off-by: Daniel Azuma <dazuma@gmail.com>
ce23938 to
4c4787b
Compare
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.
No description provided.