Skip to content

Commit 350ebcd

Browse files
committed
Fix joinPath() to handle leading directory separators correctly
1 parent c264e26 commit 350ebcd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

composer-lock-diff

+10-2
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,17 @@ function dirnameSafe($path) {
411411
}
412412

413413
function joinPath(/* path parts */) {
414-
return implode(DIRECTORY_SEPARATOR, array_map(function($part) {
414+
$args = func_get_args();
415+
$head = $args[0];
416+
$lead = '';
417+
418+
if ($head[0] == DIRECTORY_SEPARATOR) {
419+
$lead = DIRECTORY_SEPARATOR;
420+
}
421+
422+
return $lead . implode(DIRECTORY_SEPARATOR, array_map(function($part) {
415423
return trim($part, DIRECTORY_SEPARATOR);
416-
}, func_get_args()));
424+
}, $args));
417425
}
418426

419427
function ensureTrailingPathSep($path) {

0 commit comments

Comments
 (0)