Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UriResolver.php

function UriResolver::canonicalizePath

Returns the canonicalized URI path (see RFC 3986, section 5.2.4).

1 call to UriResolver::canonicalizePath()
UriResolver::resolve in vendor/symfony/dom-crawler/UriResolver.php
Resolves a URI according to a base URI.

File

vendor/symfony/dom-crawler/UriResolver.php, line 82

Class

UriResolver
The UriResolver class takes an URI (relative, absolute, fragment, etc.) and turns it into an absolute URI against another given base URI.

Namespace

Symfony\Component\DomCrawler

Code

private static function canonicalizePath(string $path) : string {
    if ('' === $path || '/' === $path) {
        return $path;
    }
    if (str_ends_with($path, '.')) {
        $path .= '/';
    }
    $output = [];
    foreach (explode('/', $path) as $segment) {
        if ('..' === $segment) {
            array_pop($output);
        }
        elseif ('.' !== $segment) {
            $output[] = $segment;
        }
    }
    return implode('/', $output);
}
RSS feed
Powered by Drupal