PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / vendor_prefixed / guzzlehttp / psr7 / src / UriComparator.php

UriComparator.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at vendor_prefixed/guzzlehttp/psr7/src/UriComparator.php

50 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace YoastSEO_Vendor\GuzzleHttp\Psr7;
5
6 use YoastSEO_Vendor\Psr\Http\Message\UriInterface;
7 /**
8 * Provides methods to determine if a modified URL should be considered cross-origin.
9 *
10 * @author Graham Campbell
11 */
12 final class UriComparator
13 {
14 /**
15 * Determines if a modified URL should be considered cross-origin with
16 * respect to an original URL.
17 */
18 public static function isCrossOrigin(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $original, \YoastSEO_Vendor\Psr\Http\Message\UriInterface $modified) : bool
19 {
20 if (!\YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::caselessEquals($original->getHost(), $modified->getHost())) {
21 return \true;
22 }
23 if ($original->getScheme() !== $modified->getScheme()) {
24 return \true;
25 }
26 if (self::computePort($original) !== self::computePort($modified)) {
27 return \true;
28 }
29 return \false;
30 }
31 private static function computePort(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri) : ?int
32 {
33 $port = $uri->getPort();
34 if (null !== $port) {
35 return $port;
36 }
37 if ('http' === $uri->getScheme()) {
38 return 80;
39 }
40 if ('https' === $uri->getScheme()) {
41 return 443;
42 }
43 return null;
44 }
45 private function __construct()
46 {
47 // cannot be instantiated
48 }
49 }
50