Skip to content

Commit

Permalink
do not use URI.encode on 1.9 (deprecated)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkh committed Mar 18, 2012
1 parent 0fb73fc commit f2bc346
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/sinatra/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1324,9 +1324,11 @@ def compile(path)
end
end

URI = ::URI.const_defined?(:Parser) ? ::URI::Parser.new : ::URI

def encoded(char)
enc = URI.encode(char)
enc = "(?:#{Regexp.escape enc}|#{URI.encode char, /./})" if enc == char
enc = URI.escape(char)
enc = "(?:#{Regexp.escape enc}|#{URI.escape char, /./})" if enc == char
enc = "(?:#{enc}|#{encoded('+')})" if char == " "
enc
end
Expand Down

0 comments on commit f2bc346

Please sign in to comment.