Permalink
Browse files

do not use URI.encode on 1.9 (deprecated)

  • Loading branch information...
rkh committed Mar 18, 2012
1 parent 2c6b6ba commit 9cdf795a952129715813d708bbf7eb934851cb22
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/sinatra/base.rb
View
@@ -1288,9 +1288,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

0 comments on commit 9cdf795

Please sign in to comment.