From fec5f2c21749134d687d05460bc6a5f8cccee783 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 31 Dec 2020 07:54:56 +0000 Subject: [PATCH] Fix a notice when the path is empty --- src/Network/Probe.php | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/Network/Probe.php b/src/Network/Probe.php index d5dcba5295..f4ca0398a8 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -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)