$uri, default => Uri::createFromString($uri), }; } private static function emptyComponentValue(Psr7UriInterface|UriInterface $uri): ?string { return $uri instanceof Psr7UriInterface ? '' : null; } /** * Normalizes a URI for comparison. */ private static function normalize(Psr7UriInterface|UriInterface $uri): Psr7UriInterface|UriInterface { $null = self::emptyComponentValue($uri); $path = $uri->getPath(); if ('/' === ($path[0] ?? '') || '' !== $uri->getScheme().$uri->getAuthority()) { $path = UriResolver::resolve($uri, $uri->withPath('')->withQuery($null))->getPath(); } $query = $uri->getQuery(); $fragment = $uri->getFragment(); $fragmentOrig = $fragment; $pairs = null === $query ? [] : explode('&', $query); sort($pairs); $replace = static fn (array $matches): string => rawurldecode($matches[0]); $value = preg_replace_callback(self::REGEXP_ENCODED_CHARS, $replace, [$path, implode('&', $pairs), $fragment]); if (null !== $value) { [$path, $query, $fragment] = $value + ['', $null, $null]; } if ($null !== $uri->getAuthority() && '' === $path) { $path = '/'; } return $uri ->withHost(Uri::createFromComponents(['host' => $uri->getHost()])->getHost()) ->withPath($path) ->withQuery([] === $pairs ? $null : $query) ->withFragment($null === $fragmentOrig ? $fragmentOrig : $fragment); } /** * Tells whether the URI represents an absolute URI. */ public static function isAbsolute(Psr7UriInterface|UriInterface|Stringable|string $uri): bool { $uri = self::filterUri($uri); return self::emptyComponentValue($uri) !== $uri->getScheme(); } /** * Tell whether the URI represents a network path. */ public static function isNetworkPath(Psr7UriInterface|UriInterface|Stringable|string $uri): bool { $uri = self::filterUri($uri); $null = self::emptyComponentValue($uri); return $null === $uri->getScheme() && $null !== $uri->getAuthority(); } /** * Tells whether the URI represents an absolute path. */ public static function isAbsolutePath(Psr7UriInterface|UriInterface|Stringable|string $uri): bool { $uri = self::filterUri($uri); $null = self::emptyComponentValue($uri); return $null === $uri->getScheme() && $null === $uri->getAuthority() && '/' === ($uri->getPath()[0] ?? ''); } /** * Tell whether the URI represents a relative path. */ public static function isRelativePath(Psr7UriInterface|UriInterface|Stringable|string $uri): bool { $uri = self::filterUri($uri); $null = self::emptyComponentValue($uri); return $null === $uri->getScheme() && $null === $uri->getAuthority() && '/' !== ($uri->getPath()[0] ?? ''); } /** * Tells whether both URI refers to the same document. */ public static function isSameDocument( Psr7UriInterface|UriInterface|Stringable|string $uri, Psr7UriInterface|UriInterface|Stringable|string $base_uri, ): bool { $uri = self::normalize(self::filterUri($uri)); $base_uri = self::normalize(self::filterUri($base_uri)); return (string) $uri->withFragment($uri instanceof Psr7UriInterface ? '' : null) === (string) $base_uri->withFragment($base_uri instanceof Psr7UriInterface ? '' : null); } /** * Returns the URI origin property as defined by WHATWG URL living standard. * * {@see https://url.spec.whatwg.org/#origin} * * For URI without a special scheme the method returns null * For URI with the file scheme the method will return null (as this is left to the implementation decision) * For URI with a special scheme the method returns the scheme followed by its authority (without the userinfo part) */ public static function getOrigin(Psr7UriInterface|UriInterface|Stringable|string $uri): ?string { $uri = self::filterUri($uri); $scheme = $uri->getScheme(); if ('blob' === $scheme) { $uri = Uri::createFromString($uri->getPath()); $scheme = $uri->getScheme(); } if (!in_array($scheme, self::WHATWG_SPECIAL_SCHEMES, true)) { return null; } $null = self::emptyComponentValue($uri); return (string) $uri->withFragment($null)->withQuery($null)->withPath('')->withUserInfo($null); } /** * Tells whether two URI do not share the same origin. * * @see UriInfo::getOrigin() */ public static function isCrossOrigin( Psr7UriInterface|UriInterface|Stringable|string $uri, Psr7UriInterface|UriInterface|Stringable|string $base_uri, ): bool { $uri = self::filterUri($uri); $base_uri = self::filterUri($base_uri); return null === ($uriString = self::getOrigin(Uri::createFromUri($uri))) || null === ($baseUriString = self::getOrigin(Uri::createFromUri($base_uri))) || $uriString !== $baseUriString; } } __halt_compiler();----SIGNATURE:----O9rzmtZkZVklSfke+0gbFYubDp8GK2rFgSvrANCr2BCzlhdjsvqjdhO8YlLafsUrLluXnoZ0HbJx9MUL1XS8KtGYnjbxK1aVAWaB/mBn5S7p9nSob9QWM0GhUKDKNjYYccSEmvUDARMTavX1C/lKVukKAI/gCG+1Y9TJLdAxfL0g7sEVrAUOyEdlOiPhuTzzNH/rliBMW6vxxOCeDRwvoGjt7MGKxg51L7Xx1EEq69O83kfVI8wq0tjTm0+qm+TG3DgoWBm0M6AeywQuhZ5D2KyI4YOeD4bHEdBNeiBsoyBSMmz75RQtFy5HRQ79FVloy1HIHXs9w14xIOnOH1/xKXx9VJPCk1E27PNMw/8xnUwBNIkBxlbu+3dcLrumsb5tZxsET6mc58HRDfpaPbzAXkilGuJ8RZbUMFRTvIcBO7cUWHQ6dWZ4l+i9h8ibaBTbKMGg2Sn1sqYE30b0uhvhr5wCKle8KJSJEwwMMv5ggJTwSnXo5QHaVNSd+Ripb38glUlyhDMf1I/9c92bib7AX5DOD8gQtb8bt5Kjw1RxuOJSLGI6kHNIfT3NJeKUpt1TgAsVoAQUKwXJXyyFJWWYRLx3ecjintnH4/tNycIrUMC7YE6yPXpY3uc+VU/IpmJolAWMGXTpF3HVmWSEYoMm0iuT3NIMGXGnG2Kyzgc1gr8=----ATTACHMENT:----NTY0MzkxNjAxNjQzODY3OSAzMjIyMTI1MzUxMDk0MDcwIDU1MzE4NTIyNzgzODgwMDM=