Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion RelativePath.Example1.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

/**
Expand Down
4 changes: 2 additions & 2 deletions RelativePath.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -83,4 +83,4 @@ public static function getRelativePath($path) {
}
return $root . implode("/", array_slice($newDirs, 0, $offset));
}
}
}