Browse Source

change haxe.io.Path.removeTrailingSlash to removeTrailingSlashes

Simon Krajewski 11 years ago
parent
commit
bbda0a64da
1 changed files with 10 additions and 7 deletions
  1. 10 7
      std/haxe/io/Path.hx

+ 10 - 7
std/haxe/io/Path.hx

@@ -199,20 +199,23 @@ class Path {
 	}
 	}
 	
 	
 	/**
 	/**
-		Removes a trailing slash from `path` if it exists.
+		Removes trailing slashes from `path`.
 		
 		
 		If `path` does not end with a `/` or `\`, `path` is returned unchanged.
 		If `path` does not end with a `/` or `\`, `path` is returned unchanged.
 		
 		
-		Otherwise the substring of `path` excluding the trailing slash or
-		backslash is returned.
+		Otherwise the substring of `path` excluding the trailing slashes or
+		backslashes is returned.
 		
 		
 		If `path` is null, the result is unspecified.
 		If `path` is null, the result is unspecified.
 	**/
 	**/
 	@:require(haxe_ver >= 3.01)
 	@:require(haxe_ver >= 3.01)
-	public static function removeTrailingSlash ( path : String ) : String {
-		return switch(path.charCodeAt(path.length - 1)) {
-			case '/'.code | '\\'.code: path.substr(0, -1);
-			case _: path;
+	public static function removeTrailingSlashes ( path : String ) : String {
+		while (true) {
+			switch(path.charCodeAt(path.length - 1)) {
+				case '/'.code | '\\'.code: path = path.substr(0, -1);
+				case _: break;
+			}
 		}
 		}
+		return path;
 	}
 	}
 }
 }