提交 03925dc2 编写于 作者: A Akira Matsuda

normalize_path used to be nil tolerant

fixes a regression introduced at 8607c25b
上级 e319b01d
......@@ -13,6 +13,7 @@ class Utils # :nodoc:
# normalize_path("") # => "/"
# normalize_path("/%ab") # => "/%AB"
def self.normalize_path(path)
path ||= ''
encoding = path.encoding
path = "/#{path}".dup
path.squeeze!("/".freeze)
......
......@@ -38,6 +38,10 @@ def test_normalize_path_maintains_string_encoding
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册