Fix. path_join function when first argument is full path.

This commit is contained in:
Alexey Melnichuk
2015-11-24 13:54:04 +03:00
parent d2f0d65842
commit 2a3b762aa2

View File

@@ -72,9 +72,22 @@ if(!function_exists('path_join')) {
$paths = array_merge($paths, (array)$arg);
}
$paths = array_map(create_function('$p', 'return trim($p, "/");'), $paths);
$prefix = null;
foreach($paths as &$path) {
if($prefix === null && strlen($path) > 0) {
if(substr($path, 0, 1) == '/') $prefix = '/';
else $prefix = '';
}
$path = trim( $path, '/' );
}
if($prefix === null){
return '';
}
$paths = array_filter($paths);
return join('/', $paths);
return $prefix . join('/', $paths);
}
}