diff --git a/RelativePath.Example1.php b/RelativePath.Example1.php index 323b45f..f120ef3 100644 --- a/RelativePath.Example1.php +++ b/RelativePath.Example1.php @@ -15,7 +15,8 @@ "../../../home/./John Doe/work/site/test/../../www/Project.1/" . "/../Project.2/index.html", "./././../../../../../../../../../home/./John Doe/work/site/test/../../www/Project.1" . "/" . "../Project.2/index.html", "../../home/../../../John Doe/work/site/test/../../www/Project.1" . "/" . "../Project.2/index.html/../", - "/media/Projects/www/test/images/../../home/../../../John Doe/work/site/test.2/../../www/Project.1"); + "/media/Projects/www/test/images/../../home/../../../John Doe/work/site/test.2/../../www/Project.1", + "c:\\Windows\\..\\Temp\\tempfile.txt"); } /** diff --git a/RelativePath.php b/RelativePath.php index 6d9ebdb..021df06 100644 --- a/RelativePath.php +++ b/RelativePath.php @@ -57,7 +57,7 @@ public static function getRelativePath($path) { if (empty($dirs[0])) { $root = "/"; $dirs = array_splice($dirs, 1); - } else if (preg_match("#[A-Za-z]:#", $dirs[0])) { + } else if (preg_match("#^[A-Za-z]:$#", $dirs[0])) { $root = strtoupper($dirs[0]) . "/"; $dirs = array_splice($dirs, 1); } @@ -83,4 +83,4 @@ public static function getRelativePath($path) { } return $root . implode("/", array_slice($newDirs, 0, $offset)); } -} \ No newline at end of file +}