lib/action_dispatch/journey/router/utils.rb in actionpack-4.2.8 vs lib/action_dispatch/journey/router/utils.rb in actionpack-4.2.9.rc1
- old
+ new
@@ -11,14 +11,16 @@
# normalize_path("/foo/") # => "/foo"
# normalize_path("foo") # => "/foo"
# normalize_path("") # => "/"
# normalize_path("/%ab") # => "/%AB"
def self.normalize_path(path)
+ encoding = path.encoding
path = "/#{path}"
path.squeeze!('/')
path.sub!(%r{/+\Z}, '')
path.gsub!(/(%[a-f0-9]{2})/) { $1.upcase }
- path = '/' if path == ''
+ path = "/" if path == "".freeze
+ path.force_encoding(encoding)
path
end
# URI path and fragment escaping
# http://tools.ietf.org/html/rfc3986