1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

Remove unnecessary code for force_encoding

Since Rack 2 requires Ruby 2.2+, the extra logic for determining
string encoding is no longer necessary. Outdated comments were
also removed.
This commit is contained in:
Jordan Owens 2019-04-12 12:36:18 -04:00
parent 7b7043cde3
commit 6b96449a6e

View file

@ -1743,14 +1743,8 @@ module Sinatra
end
end
# Fixes encoding issues by
# * defaulting to UTF-8
# * casting params to Encoding.default_external
#
# The latter might not be necessary if Rack handles it one day.
# Keep an eye on Rack's LH #100.
def force_encoding(*args) settings.force_encoding(*args) end
if defined? Encoding
# Force data to specified encoding. It defaults to settings.default_encoding
# which is UTF-8 by default
def self.force_encoding(data, encoding = default_encoding)
return if data == settings || data.is_a?(Tempfile)
if data.respond_to? :force_encoding
@ -1762,9 +1756,8 @@ module Sinatra
end
data
end
else
def self.force_encoding(data, *) data end
end
def force_encoding(*args) settings.force_encoding(*args) end
reset!