lib/file: remove all trailing / on String::dirname
authorJean Privat <jean@pryen.org>
Fri, 14 Mar 2014 20:22:19 +0000 (16:22 -0400)
committerJean Privat <jean@pryen.org>
Fri, 14 Mar 2014 20:22:19 +0000 (16:22 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/standard/file.nit

index 4ba20a0..b23e86c 100644 (file)
@@ -263,7 +263,7 @@ redef class String
        fun dirname: String
        do
                var l = _length - 1 # Index of the last char
-               if l > 0 and self.chars[l] == '/' then l -= 1 # remove trailing `/`
+               while l > 0 and self.chars[l] == '/' do l -= 1 # remove all trailing `/`
                var pos = last_index_of_from('/', l)
                if pos > 0 then
                        return substring(0, pos)