Browse Source

Fix haxe.io.Path.isAbsolute for windows and add unit tests for it.

Dan Korostelev 10 years ago
parent
commit
52957c238c
2 changed files with 9 additions and 2 deletions
  1. 1 1
      std/haxe/io/Path.hx
  2. 8 1
      tests/unit/src/unitstd/haxe/io/Path.unit.hx

+ 1 - 1
std/haxe/io/Path.hx

@@ -305,7 +305,7 @@ class Path {
 	**/
 	public static function isAbsolute ( path : String ) : Bool {
 		if (StringTools.startsWith(path, '/')) return true;
-		if (path.charAt(2) == ':') return true;
+		if (path.charAt(1) == ':') return true;
 		return false;
 	}
 }

+ 8 - 1
tests/unit/src/unitstd/haxe/io/Path.unit.hx

@@ -102,4 +102,11 @@ haxe.io.Path.addTrailingSlash("a/b") == "a/b/";
 haxe.io.Path.addTrailingSlash("a/b/") == "a/b/";
 haxe.io.Path.addTrailingSlash("a\\") == "a\\";
 haxe.io.Path.addTrailingSlash("a\\b") == "a\\b\\";
-haxe.io.Path.addTrailingSlash("a\\b\\") == "a\\b\\";
+haxe.io.Path.addTrailingSlash("a\\b\\") == "a\\b\\";
+
+// isAbsolute
+haxe.io.Path.isAbsolute("") == false;
+haxe.io.Path.isAbsolute("some") == false;
+haxe.io.Path.isAbsolute("some/other") == false;
+haxe.io.Path.isAbsolute("/some") == true;
+haxe.io.Path.isAbsolute("c:/some") == true;