mirror of
https://github.com/friendica/friendica
synced 2024-11-10 03:02:54 +00:00
Fix a notice when the path is empty
This commit is contained in:
parent
934f69a426
commit
fec5f2c217
1 changed files with 19 additions and 17 deletions
|
@ -1801,26 +1801,28 @@ class Probe
|
|||
|
||||
$hrefParts = parse_url($href);
|
||||
|
||||
// Root path case (/path) including relative scheme case (//host/path)
|
||||
if ($hrefParts['path'] && $hrefParts['path'][0] == '/') {
|
||||
$path = $hrefParts['path'];
|
||||
} else {
|
||||
$path = $path . '/' . $hrefParts['path'];
|
||||
if (!empty($hrefParts['path'])) {
|
||||
// Root path case (/path) including relative scheme case (//host/path)
|
||||
if ($hrefParts['path'] && $hrefParts['path'][0] == '/') {
|
||||
$path = $hrefParts['path'];
|
||||
} else {
|
||||
$path = $path . '/' . $hrefParts['path'];
|
||||
|
||||
// Resolve arbitrary relative path
|
||||
// Lifted from https://www.php.net/manual/en/function.realpath.php#84012
|
||||
$parts = array_filter(explode('/', $path), 'strlen');
|
||||
$absolutes = array();
|
||||
foreach ($parts as $part) {
|
||||
if ('.' == $part) continue;
|
||||
if ('..' == $part) {
|
||||
array_pop($absolutes);
|
||||
} else {
|
||||
$absolutes[] = $part;
|
||||
// Resolve arbitrary relative path
|
||||
// Lifted from https://www.php.net/manual/en/function.realpath.php#84012
|
||||
$parts = array_filter(explode('/', $path), 'strlen');
|
||||
$absolutes = array();
|
||||
foreach ($parts as $part) {
|
||||
if ('.' == $part) continue;
|
||||
if ('..' == $part) {
|
||||
array_pop($absolutes);
|
||||
} else {
|
||||
$absolutes[] = $part;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$path = '/' . implode('/', $absolutes);
|
||||
$path = '/' . implode('/', $absolutes);
|
||||
}
|
||||
}
|
||||
|
||||
// Relative scheme case (//host/path)
|
||||
|
|
Loading…
Reference in a new issue