You are here

public static function Uri::isSameDocumentReference in Lockr 7.3

Whether the URI is a same-document reference.

A same-document reference refers to a URI that is, aside from its fragment component, identical to the base URI. When no base URI is given, only an empty URI reference (apart from its fragment) is considered a same-document reference.

@link https://tools.ietf.org/html/rfc3986#section-4.4

Parameters

UriInterface $uri The URI to check:

UriInterface|null $base An optional base URI to compare against:

Return value

bool

File

vendor/guzzlehttp/psr7/src/Uri.php, line 242

Class

Uri
PSR-7 URI implementation.

Namespace

GuzzleHttp\Psr7

Code

public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null) {
  if ($base !== null) {
    $uri = UriResolver::resolve($base, $uri);
    return $uri
      ->getScheme() === $base
      ->getScheme() && $uri
      ->getAuthority() === $base
      ->getAuthority() && $uri
      ->getPath() === $base
      ->getPath() && $uri
      ->getQuery() === $base
      ->getQuery();
  }
  return $uri
    ->getScheme() === '' && $uri
    ->getAuthority() === '' && $uri
    ->getPath() === '' && $uri
    ->getQuery() === '';
}