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

Breadcrumb

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

function AbstractUriElement::canonicalizePath

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

Parameters

string $path URI path:

File

vendor/symfony/dom-crawler/AbstractUriElement.php, line 80

Class

AbstractUriElement
Any HTML element that can link to an URI.

Namespace

Symfony\Component\DomCrawler

Code

protected 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