YoastSEO_Vendor\GuzzleHttp\Psr7
UriResolver::getRelativePath() private Yoast 1.0
{} Это метод класса: UriResolver{}
Хуков нет.
Возвращает
Null. Ничего.
Использование
$result = UriResolver::getRelativePath( \YoastSEO_Vendor\Psr\Http\Message\UriInterface $base, \YoastSEO_Vendor\Psr\Http\Message\UriInterface $target );
Код UriResolver::getRelativePath() UriResolver::getRelativePath Yoast 15.6.2
private static function getRelativePath(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $base, \YoastSEO_Vendor\Psr\Http\Message\UriInterface $target)
{
$sourceSegments = \explode('/', $base->getPath());
$targetSegments = \explode('/', $target->getPath());
\array_pop($sourceSegments);
$targetLastSegment = \array_pop($targetSegments);
foreach ($sourceSegments as $i => $segment) {
if (isset($targetSegments[$i]) && $segment === $targetSegments[$i]) {
unset($sourceSegments[$i], $targetSegments[$i]);
} else {
break;
}
}
$targetSegments[] = $targetLastSegment;
$relativePath = \str_repeat('../', \count($sourceSegments)) . \implode('/', $targetSegments);
// A reference to am empty last segment or an empty first sub-segment must be prefixed with "./".
// This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used
// as the first segment of a relative-path reference, as it would be mistaken for a scheme name.
if ('' === $relativePath || \false !== \strpos(\explode('/', $relativePath, 2)[0], ':')) {
$relativePath = "./{$relativePath}";
} elseif ('/' === $relativePath[0]) {
if ($base->getAuthority() != '' && $base->getPath() === '') {
// In this case an extra slash is added by resolve() automatically. So we must not add one here.
$relativePath = ".{$relativePath}";
} else {
$relativePath = "./{$relativePath}";
}
}
return $relativePath;
}