public function getPath(): string
    {
        // Removing duplicated slashes.
        $uri = str_replace('//', '/', $this->getUrl());

        $uri = Uri\normalize($uri);
        $baseUri = Uri\normalize($this->getBaseUrl());

        if (0 === strpos($uri, $baseUri)) {
            // We're not interested in the query part (everything after the ?).
            list($uri) = explode('?', $uri);

            return trim(decodePath(substr($uri, strlen($baseUri))), '/');
        }

        if ($uri.'/' === $baseUri) {
            return '';
        }
        // A special case, if the baseUri was accessed without a trailing
        // slash, we'll accept it as well.

        throw new \LogicException('Requested uri ('.$this->getUrl().') is out of base uri ('.$this->getBaseUrl().')');
    }
public function getPath(): string
    {
        // Removing duplicated slashes.
        $uri = str_replace('//', '/', $this->getUrl());

        $uri = Uri\normalize($uri);
        $baseUri = Uri\normalize($this->getBaseUrl());

        if (0 === strpos($uri, $baseUri)) {
            // We're not interested in the query part (everything after the ?).
            list($uri) = explode('?', $uri);

            return trim(decodePath(substr($uri, strlen($baseUri))), '/');
        }

        if ($uri.'/' === $baseUri) {
            return '';
        }
        // A special case, if the baseUri was accessed without a trailing
        // slash, we'll accept it as well.

        throw new \LogicException('Requested uri ('.$this->getUrl().') is out of base uri ('.$this->getBaseUrl().')');
    }
public function getPath ( ) : string { // Removing duplicated slashes. $ uri = str_replace ( '//' , '/' , $ this -> getUrl ( ) ) ; $ uri = Uri \ normalize ( $ uri ) ; $ baseUri = Uri \ normalize ( $ this -> getBaseUrl ( ) ) ; if ( 0 === strpos ( $ uri , $ baseUri ) ) { // We're not interested in the query part (everything after the ?). list ( $ uri ) = explode ( '?' , $ uri ) ; return trim ( decodePath ( substr ( $ uri , strlen ( $ baseUri ) ) ) , '/' ) ; } if ( $ uri . '/' === $ baseUri ) { return '' ; } // A special case, if the baseUri was accessed without a trailing // slash, we'll accept it as well. throw new \ LogicException ( 'Requested uri (' . $ this -> getUrl ( ) . ') is out of base uri (' . $ this -> getBaseUrl ( ) . ')' ) ; }
Returns the relative path.

This is being calculated using the base url. This path will not start
with a slash, so it will always return something like
'example/path.html'.

If the full path is equal to the base url, this method will return an
empty string.

This method will also urldecode the path, and if the url was incoded as
ISO-8859-1, it will convert it to UTF-8.

If the path is outside of the base url, a LogicException will be thrown.
Returns the relative path .