Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

also set charset for json

  • Loading branch information...
commit 07c272d6320a7c3cb99bb4b76ea69a5ada376b9d 1 parent b391e7f
@rkh rkh authored
Showing with 3 additions and 1 deletion.
  1. +2 −1  lib/sinatra/base.rb
  2. +1 −0  test/helpers_test.rb
View
3  lib/sinatra/base.rb
@@ -1300,7 +1300,8 @@ def self.force_encoding(data, *) data end
set :logging, false
set :method_override, false
set :default_encoding, "utf-8"
- set :add_charset, [/^text\//, 'application/javascript', 'application/xml', 'application/xhtml+xml']
+ set :add_charset, %w[javascript xml xhtml+xml json].map { |t| "application/#{t}" }
+ settings.add_charset << /^text\//
# explicitly generating a session secret eagerly to play nice with preforking
begin
View
1  test/helpers_test.rb
@@ -446,6 +446,7 @@ def test_default
assert_equal content_type(:xml), 'application/xml;charset=utf-8'
assert_equal content_type(:xhtml), 'application/xhtml+xml;charset=utf-8'
assert_equal content_type(:js), 'application/javascript;charset=utf-8'
+ assert_equal content_type(:json), 'application/json;charset=utf-8'
assert_equal content_type(:bar), 'application/bar'
assert_equal content_type(:png), 'image/png'
assert_equal content_type(:baz), 'application/baz;charset=utf-8'
Please sign in to comment.
Something went wrong with that request. Please try again.