lib: fix simplify_path for .
authorJean Privat <jean@pryen.org>
Wed, 29 Jan 2014 21:04:59 +0000 (16:04 -0500)
committerJean Privat <jean@pryen.org>
Wed, 29 Jan 2014 21:05:15 +0000 (16:05 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/standard/file.nit

index 9114ff1..964331a 100644 (file)
@@ -261,9 +261,10 @@ redef class String
        #  * the validity of the path is not checked
        #
        #     assert "some/./complex/../../path/from/../to/a////file//".simplify_path        ==  "path/to/a/file"
-       #     assert "../dir/file".simplify_path      ==  "../dir/file"
-       #     assert "dir/../../".simplify_path      ==  ".."
-       #     assert "//absolute//path/".simplify_path      ==  "/absolute/path"
+       #     assert "../dir/file".simplify_path       ==  "../dir/file"
+       #     assert "dir/../../".simplify_path        ==  ".."
+       #     assert "dir/..".simplify_path            ==  "."
+       #     assert "//absolute//path/".simplify_path ==  "/absolute/path"
        fun simplify_path: String
        do
                var a = self.split_with("/")
@@ -277,6 +278,7 @@ redef class String
                        end
                        a2.push(x)
                end
+               if a2.is_empty then return "."
                return a2.join("/")
        end