public static function UriResolver::resolve in Lockr 7.3
Converts the relative URI into a new URI that is resolved against the base URI.
@link http://tools.ietf.org/html/rfc3986#section-5.2
Parameters
UriInterface $base Base URI:
UriInterface $rel Relative URI:
Return value
2 calls to UriResolver::resolve()
- Uri::isSameDocumentReference in vendor/
guzzlehttp/ psr7/ src/ Uri.php - Whether the URI is a same-document reference.
- Uri::resolve in vendor/
guzzlehttp/ psr7/ src/ Uri.php - Converts the relative URI into a new URI that is resolved against the base URI.
File
- vendor/
guzzlehttp/ psr7/ src/ UriResolver.php, line 62
Class
- UriResolver
- Resolves a URI reference in the context of a base URI and the opposite way.
Namespace
GuzzleHttp\Psr7Code
public static function resolve(UriInterface $base, UriInterface $rel) {
if ((string) $rel === '') {
// we can simply return the same base URI instance for this same-document reference
return $base;
}
if ($rel
->getScheme() != '') {
return $rel
->withPath(self::removeDotSegments($rel
->getPath()));
}
if ($rel
->getAuthority() != '') {
$targetAuthority = $rel
->getAuthority();
$targetPath = self::removeDotSegments($rel
->getPath());
$targetQuery = $rel
->getQuery();
}
else {
$targetAuthority = $base
->getAuthority();
if ($rel
->getPath() === '') {
$targetPath = $base
->getPath();
$targetQuery = $rel
->getQuery() != '' ? $rel
->getQuery() : $base
->getQuery();
}
else {
if ($rel
->getPath()[0] === '/') {
$targetPath = $rel
->getPath();
}
else {
if ($targetAuthority != '' && $base
->getPath() === '') {
$targetPath = '/' . $rel
->getPath();
}
else {
$lastSlashPos = strrpos($base
->getPath(), '/');
if ($lastSlashPos === false) {
$targetPath = $rel
->getPath();
}
else {
$targetPath = substr($base
->getPath(), 0, $lastSlashPos + 1) . $rel
->getPath();
}
}
}
$targetPath = self::removeDotSegments($targetPath);
$targetQuery = $rel
->getQuery();
}
}
return new Uri(Uri::composeComponents($base
->getScheme(), $targetAuthority, $targetPath, $targetQuery, $rel
->getFragment()));
}