original_string: protected static function updatePath($base, $uri)
      {
          $path = $uri->getPath();
          if (strlen($base) > 0 && strpos($path, $base) === 0) {
              $path = substr($path, strlen($base));
          }
          if ($path === '/index.php' && $uri->getQuery()) {
              $path = $uri->getQuery();
          }
          if (empty($path) || $path === '/' || $path === '//' || $path === '/index.php') {
              $path = '/';
          }
          $endsWithIndex = '/' . (Configure::read('App.webroot') ?: 'webroot') . '/index.php';
          $endsWithLength = strlen($endsWithIndex);
          if (strlen($path) >= $endsWithLength &&
              substr($path, -$endsWithLength) === $endsWithIndex
          ) {
              $path = '/';
          }
  
          return $uri->withPath($path);
      }
code: protected static function updatePath($base, $uri)
      {
          $path = $uri->getPath();
          if (strlen($base) > 0 && strpos($path, $base) === 0) {
              $path = substr($path, strlen($base));
          }
          if ($path === '/index.php' && $uri->getQuery()) {
              $path = $uri->getQuery();
          }
          if (empty($path) || $path === '/' || $path === '//' || $path === '/index.php') {
              $path = '/';
          }
          $endsWithIndex = '/' . (Configure::read('App.webroot') ?: 'webroot') . '/index.php';
          $endsWithLength = strlen($endsWithIndex);
          if (strlen($path) >= $endsWithLength &&
              substr($path, -$endsWithLength) === $endsWithIndex
          ) {
              $path = '/';
          }
  
          return $uri->withPath($path);
      }
code_tokens: protected static function updatePath ( $ base , $ uri ) { $ path = $ uri -> getPath ( ) ; if ( strlen ( $ base ) > 0 && strpos ( $ path , $ base ) === 0 ) { $ path = substr ( $ path , strlen ( $ base ) ) ; } if ( $ path === '/index.php' && $ uri -> getQuery ( ) ) { $ path = $ uri -> getQuery ( ) ; } if ( empty ( $ path ) || $ path === '/' || $ path === '//' || $ path === '/index.php' ) { $ path = '/' ; } $ endsWithIndex = '/' . ( Configure :: read ( 'App.webroot' ) ? : 'webroot' ) . '/index.php' ; $ endsWithLength = strlen ( $ endsWithIndex ) ; if ( strlen ( $ path ) >= $ endsWithLength && substr ( $ path , - $ endsWithLength ) === $ endsWithIndex ) { $ path = '/' ; } return $ uri -> withPath ( $ path ) ; }
docstring: Updates the request URI to remove the base directory.
  
  @param string $base The base path to remove.
  @param \Psr\Http\Message\UriInterface $uri The uri to update.
  @return \Psr\Http\Message\UriInterface The modified Uri instance.
docstring_tokens: Updates the request URI to remove the base directory .