Jelajahi Sumber

do not normalize http:// into http:/

Simon Krajewski 11 tahun lalu
induk
melakukan
3f213bc912
2 mengubah file dengan 6 tambahan dan 5 penghapusan
  1. 5 5
      std/haxe/io/Path.hx
  2. 1 0
      tests/unit/unitstd/haxe/io/Path.unit.hx

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

@@ -207,7 +207,6 @@ class Path {
 			return slash;
 		}
 
-		var prependSlash = (path.charAt(0) == slash || path.charAt(0) == '.');
 		var target = [];
 		var src;
 		var parts;
@@ -219,14 +218,15 @@ class Path {
 
 			if(token == '..') {
 				target.pop();
-			} else if(token != '' && token != '.') {
+			} else if(token != '.') {
 				target.push(token);
 			}
 		}
-		var regex = ~/\/\//g;
+		
+		var regex = ~/([^:])\/+/g;
 		var tmp = target.join(slash);
-		var result = regex.replace(tmp, slash);
-		return (prependSlash ? slash : '') + result;
+		var result = regex.replace(tmp, "$1" +slash);
+		return result;
 	}
 
 	/**

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

@@ -65,6 +65,7 @@ haxe.io.Path.normalize("dir1/dir2/../dir3") == "dir1/dir3";
 haxe.io.Path.normalize("/dir1/dir2/../../test.foo") == "/test.foo";
 haxe.io.Path.normalize("dir1/dir2/dir3/dir4/../../../dir5") == "dir1/dir5";
 haxe.io.Path.normalize("C:\\Windows\\..\\Users/Waneck on Windows///.haxelib") == "C:/Users/Waneck on Windows/.haxelib";
+haxe.io.Path.normalize("http://haxe.org/downloads") == "http://haxe.org/downloads";
 
 // join
 haxe.io.Path.join(["dir1/dir2", "dir3/dir4"]) == "dir1/dir2/dir3/dir4";