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\DomCrawlerCode
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);
}