Skip to content

Commit

Permalink
Remove Ruby 1.8 compatibility code
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Jun 12, 2024
1 parent 18a2efc commit af804ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion demo-site/config.ru
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Encoding.default_internal = Encoding.default_external = 'UTF-8' if RUBY_VERSION >= '1.9'
Encoding.default_internal = Encoding.default_external = 'UTF-8'
require ::File.expand_path('../forme_demo', __FILE__)
run FormeDemo::App.app
14 changes: 4 additions & 10 deletions lib/forme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,10 @@ def self.h(value)
rescue LoadError
ESCAPE_TABLE = {'&' => '&amp;', '<' => '&lt;', '>' => '&gt;', '"' => '&quot;', "'" => '&#39;'}.freeze
ESCAPE_TABLE.each_value(&:freeze)
if RUBY_VERSION >= '1.9'
# Escape the following characters with their HTML/XML
# equivalents.
def self.h(value)
value.to_s.gsub(/[&<>"']/, ESCAPE_TABLE)
end
else
def self.h(value)
value.to_s.gsub(/[&<>"']/){|s| ESCAPE_TABLE[s]}
end
# Escape the following characters with their HTML/XML
# equivalents.
def self.h(value)
value.to_s.gsub(/[&<>"']/, ESCAPE_TABLE)
end
end
end
Expand Down

0 comments on commit af804ea

Please sign in to comment.