Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/context_dev/internal/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions test/context_dev/internal/util_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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