lib/standard: assert "/home/../".simplify_path == "/"
authorJean Privat <jean@pryen.org>
Wed, 23 Jul 2014 16:48:41 +0000 (12:48 -0400)
committerJean Privat <jean@pryen.org>
Wed, 23 Jul 2014 16:48:41 +0000 (12:48 -0400)
Fixes #614

Signed-off-by: Jean Privat <jean@pryen.org>

lib/standard/file.nit

index de0da82..862f145 100644 (file)
@@ -306,6 +306,7 @@ redef class String
        #     assert "dir/../../".simplify_path        ==  ".."
        #     assert "dir/..".simplify_path            ==  "."
        #     assert "//absolute//path/".simplify_path ==  "/absolute/path"
+       #     assert "//absolute//../".simplify_path   ==  "/"
        fun simplify_path: String
        do
                var a = self.split_with("/")
@@ -320,6 +321,7 @@ redef class String
                        a2.push(x)
                end
                if a2.is_empty then return "."
+               if a2.length == 1 and a2.first == "" then return "/"
                return a2.join("/")
        end