1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

normalize_path used to be nil tolerant

fixes a regression introduced at 8607c25ba7
This commit is contained in:
Akira Matsuda 2017-07-12 19:48:31 +09:00
parent e319b01de8
commit 03925dc26a
2 changed files with 5 additions and 0 deletions

View file

@ -13,6 +13,7 @@ module ActionDispatch
# normalize_path("") # => "/"
# normalize_path("/%ab") # => "/%AB"
def self.normalize_path(path)
path ||= ''
encoding = path.encoding
path = "/#{path}".dup
path.squeeze!("/".freeze)

View file

@ -38,6 +38,10 @@ module ActionDispatch
path = "/foo%AAbar%AAbaz".b
assert_equal Encoding::ASCII_8BIT, Utils.normalize_path(path).encoding
end
def test_normalize_path_with_nil
assert_equal '/', Utils.normalize_path(nil)
end
end
end
end