src/VDB/Uri/Uri.php
private function normalizeDotSegments()
    {
        $input = explode('/', $this->path);
        $output = array();

        while (!empty($input)) {
            if ('..' === $input[0]) {
                if (1 === count($input)) {
                    array_shift($input);
                    if ('' !== end($output)) {
                        array_pop($output);
                    }
                    array_push($output, '');
                } else {
                    array_shift($input);
                    if ('' !== end($output)) {
                        array_pop($output);
                    }
                }
            } elseif ('.' === $input[0]) {
                if (1 === count($input)) {
                    array_shift($input);
                    array_push($output, '');
                } else {
                    array_shift($input);
                }
            } else {
                array_push($output, array_shift($input));
            }
        }
        $this->path = implode('/', $output);
    }
private function normalizeDotSegments()
    {
        $input = explode('/', $this->path);
        $output = array();

        while (!empty($input)) {
            if ('..' === $input[0]) {
                if (1 === count($input)) {
                    array_shift($input);
                    if ('' !== end($output)) {
                        array_pop($output);
                    }
                    array_push($output, '');
                } else {
                    array_shift($input);
                    if ('' !== end($output)) {
                        array_pop($output);
                    }
                }
            } elseif ('.' === $input[0]) {
                if (1 === count($input)) {
                    array_shift($input);
                    array_push($output, '');
                } else {
                    array_shift($input);
                }
            } else {
                array_push($output, array_shift($input));
            }
        }
        $this->path = implode('/', $output);
    }
private function normalizeDotSegments ( ) { $ input = explode ( '/' , $ this -> path ) ; $ output = array ( ) ; while ( ! empty ( $ input ) ) { if ( '..' === $ input [ 0 ] ) { if ( 1 === count ( $ input ) ) { array_shift ( $ input ) ; if ( '' !== end ( $ output ) ) { array_pop ( $ output ) ; } array_push ( $ output , '' ) ; } else { array_shift ( $ input ) ; if ( '' !== end ( $ output ) ) { array_pop ( $ output ) ; } } } elseif ( '.' === $ input [ 0 ] ) { if ( 1 === count ( $ input ) ) { array_shift ( $ input ) ; array_push ( $ output , '' ) ; } else { array_shift ( $ input ) ; } } else { array_push ( $ output , array_shift ( $ input ) ) ; } } $ this -> path = implode ( '/' , $ output ) ; }
From RFC 3986 paragraph 5.2.4

1.  The input buffer is initialized with the now-appended path
components and the output buffer is initialized to the empty
string.

2.  While the input buffer is not empty, loop as follows:

A.  If the input buffer begins with a prefix of "../" or "./",
then remove that prefix from the input buffer; otherwise,

B.  if the input buffer begins with a prefix of "/./" or "/.",
where "." is a complete path segment, then replace that
prefix with "/" in the input buffer; otherwise,

C.  if the input buffer begins with a prefix of "/../" or "/..",
where ".." is a complete path segment, then replace that
prefix with "/" in the input buffer and remove the last
segment and its preceding "/" (if any) from the output
buffer; otherwise,

D.  if the input buffer consists only of "." or "..", then remove
that from the input buffer; otherwise,

E.  move the first path segment in the input buffer to the end of
the output buffer, including the initial "/" character (if
any) and any subsequent characters up to, but not including,
the next "/" character or the end of the input buffer.

3.  Finally, the output buffer is returned as the result of
remove_dot_segments.
From RFC 3986 paragraph 5 . 2 . 4