Skip to content

Commit 60bf3f3

Browse files
fix(client): loosen json header parsing
1 parent fd0b56a commit 60bf3f3

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

lib/orb/internal/util.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ def writable_enum(&blk)
485485
end
486486

487487
# @type [Regexp]
488-
JSON_CONTENT = %r{^application/(?:vnd(?:\.[^.]+)*\+)?json(?!l)}
488+
JSON_CONTENT = %r{^application/(?:[a-zA-Z0-9.-]+\+)?json(?!l)}
489489
# @type [Regexp]
490490
JSONL_CONTENT = %r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}
491491

rbi/orb/internal/util.rbi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ module Orb
290290
end
291291

292292
JSON_CONTENT =
293-
T.let(%r{^application/(?:vnd(?:\.[^.]+)*\+)?json(?!l)}, Regexp)
293+
T.let(%r{^application/(?:[a-zA-Z0-9.-]+\+)?json(?!l)}, Regexp)
294294
JSONL_CONTENT =
295295
T.let(%r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}, Regexp)
296296

test/orb/internal/util_test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ def test_json_content
171171
cases = {
172172
"application/json" => true,
173173
"application/jsonl" => false,
174+
"application/arbitrary+json" => true,
175+
"application/ARBITRARY+json" => true,
174176
"application/vnd.github.v3+json" => true,
175177
"application/vnd.api+json" => true
176178
}

0 commit comments

Comments
 (0)