Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Windows paths handling for paths with ':'. #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Fixed Windows paths handling for paths with ':'.
A path with a colon is not necessarily a Windows
path.
  • Loading branch information
egilli committed Sep 17, 2016
commit ef5c82e5a5b82c4d1595eadda8ba521a798dd08b
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));
}
}
}