diff --git a/lib/context_dev/internal/util.rb b/lib/context_dev/internal/util.rb index 1c922103..154a8a65 100644 --- a/lib/context_dev/internal/util.rb +++ b/lib/context_dev/internal/util.rb @@ -501,7 +501,7 @@ def writable_enum(&blk) # @type [Regexp] JSON_CONTENT = %r{^application/(?:[a-zA-Z0-9.-]+\+)?json(?!l)} # @type [Regexp] - JSONL_CONTENT = %r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)} + JSONL_CONTENT = %r{^application/(?:x-(?:n|l)djson|(?:x-)?jsonl)} class << self # @api private diff --git a/test/context_dev/internal/util_test.rb b/test/context_dev/internal/util_test.rb index 1dfca4d2..af0a8d03 100644 --- a/test/context_dev/internal/util_test.rb +++ b/test/context_dev/internal/util_test.rb @@ -673,3 +673,28 @@ def test_decode_sse end end end + +class ContextDev::Test::UtilJsonlContentTest < Minitest::Test + def test_jsonl_content_type + matched = [ + "application/jsonl", + "application/x-jsonl", + "application/x-ndjson", + "application/x-ldjson" + ] + rejected = [ + "text/jsonl", + "application/octet-stream; filename=data.jsonl", + "random_jsonl", + "text/plain" + ] + + matched.each do |content_type| + assert_match(ContextDev::Internal::Util::JSONL_CONTENT, content_type) + end + + rejected.each do |content_type| + refute_match(ContextDev::Internal::Util::JSONL_CONTENT, content_type) + end + end +end