← All changes
|
vendor_prefixed/guzzlehttp/psr7/src/UriResolver.php
+16
-20
27.9
→
trunk
View file →
| @@ -57,36 +57,32 @@ | ||
| 57 | 57 | if ($rel->getScheme() != '') { |
| 58 | 58 | return $rel->withPath(self::removeDotSegments($rel->getPath())); |
| 59 | 59 | } |
| 60 | 60 | if ($rel->getAuthority() != '') { |
| 61 | - $targetAuthority = $rel->getAuthority(); | |
| 62 | - $targetPath = self::removeDotSegments($rel->getPath()); | |
| 63 | - $targetQuery = $rel->getQuery(); | |
| 61 | + return $rel->withScheme($base->getScheme())->withPath(self::removeDotSegments($rel->getPath())); | |
| 62 | + } | |
| 63 | + if ($rel->getPath() === '') { | |
| 64 | + $targetPath = $base->getPath(); | |
| 65 | + $targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery(); | |
| 64 | 66 | } else { |
| 65 | - $targetAuthority = $base->getAuthority(); | |
| 66 | - if ($rel->getPath() === '') { | |
| 67 | - $targetPath = $base->getPath(); | |
| 68 | - $targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery(); | |
| 67 | + if ($rel->getPath()[0] === '/') { | |
| 68 | + $targetPath = $rel->getPath(); | |
| 69 | 69 | } else { |
| 70 | - if ($rel->getPath()[0] === '/') { | |
| 71 | - $targetPath = $rel->getPath(); | |
| 70 | + if ($base->getAuthority() != '' && $base->getPath() === '') { | |
| 71 | + $targetPath = '/' . $rel->getPath(); | |
| 72 | 72 | } else { |
| 73 | - if ($targetAuthority != '' && $base->getPath() === '') { | |
| 74 | - $targetPath = '/' . $rel->getPath(); | |
| 73 | + $lastSlashPos = \strrpos($base->getPath(), '/'); | |
| 74 | + if ($lastSlashPos === \false) { | |
| 75 | + $targetPath = $rel->getPath(); | |
| 75 | 76 | } else { |
| 76 | - $lastSlashPos = \strrpos($base->getPath(), '/'); | |
| 77 | - if ($lastSlashPos === \false) { | |
| 78 | - $targetPath = $rel->getPath(); | |
| 79 | - } else { | |
| 80 | - $targetPath = \substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath(); | |
| 81 | - } | |
| 77 | + $targetPath = \substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath(); | |
| 82 | 78 | } |
| 83 | 79 | } |
| 84 | - $targetPath = self::removeDotSegments($targetPath); | |
| 85 | - $targetQuery = $rel->getQuery(); | |
| 86 | 80 | } |
| 81 | + $targetPath = self::removeDotSegments($targetPath); | |
| 82 | + $targetQuery = $rel->getQuery(); | |
| 87 | 83 | } |
| 88 | - return new \YoastSEO_Vendor\GuzzleHttp\Psr7\Uri(\YoastSEO_Vendor\GuzzleHttp\Psr7\Uri::composeComponents($base->getScheme(), $targetAuthority, $targetPath, $targetQuery, $rel->getFragment())); | |
| 84 | + return $base->withPath($targetPath)->withQuery($targetQuery)->withFragment($rel->getFragment()); | |
| 89 | 85 | } |
| 90 | 86 | /** |
| 91 | 87 | * Returns the target URI as a relative reference from the base URI. |
| 92 | 88 | * |