PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.1.10
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.1.10
4.1.20 4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 All 174 releases
searchpro / BerqWP / vendor / guzzlehttp / psr7 / src / UriComparator.php

UriComparator.php in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript 4.1.10, at BerqWP/vendor/guzzlehttp/psr7/src/UriComparator.php

53 lines 1.1 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
5 namespace GuzzleHttp\Psr7;
6
7 use Psr\Http\Message\UriInterface;
8
9 /**
10 * Provides methods to determine if a modified URL should be considered cross-origin.
11 *
12 * @author Graham Campbell
13 */
14 final class UriComparator
15 {
16 /**
17 * Determines if a modified URL should be considered cross-origin with
18 * respect to an original URL.
19 */
20 public static function isCrossOrigin(UriInterface $original, UriInterface $modified): bool
21 {
22 if (\strcasecmp($original->getHost(), $modified->getHost()) !== 0) {
23 return true;
24 }
25
26 if ($original->getScheme() !== $modified->getScheme()) {
27 return true;
28 }
29
30 if (self::computePort($original) !== self::computePort($modified)) {
31 return true;
32 }
33
34 return false;
35 }
36
37 private static function computePort(UriInterface $uri): int
38 {
39 $port = $uri->getPort();
40
41 if (null !== $port) {
42 return $port;
43 }
44
45 return 'https' === $uri->getScheme() ? 443 : 80;
46 }
47
48 private function __construct()
49 {
50 // cannot be instantiated
51 }
52 }
53