code: protected function chompPath(&$url)
      {
          if (preg_match('/(.*?)(\?|#|$)(.*)/', $url, $matches)) {
              $url = $matches[2] . $matches[3];
  
              return ($matches[1] ? $matches[1] : '');
          }
  
          return '';
      }
docs: Extracts the path information from the incoming URL. Strips this path from the URL.
  
  @param string $url     URL so far. The host will be removed.
  
  @return string         Path part or '/'.