original_string: public static function normalize($url = '/')
      {
          if (is_array($url)) {
              $url = static::url($url);
          }
          if (preg_match('/^[a-z\-]+:\/\//', $url)) {
              return $url;
          }
          $request = static::getRequest();
  
          if ($request) {
              $base = $request->getAttribute('base');
              if (strlen($base) && stristr($url, $base)) {
                  $url = preg_replace('/^' . preg_quote($base, '/') . '/', '', $url, 1);
              }
          }
          $url = '/' . $url;
  
          while (strpos($url, '//') !== false) {
              $url = str_replace('//', '/', $url);
          }
          $url = preg_replace('/(?:(\/$))/', '', $url);
  
          if (empty($url)) {
              return '/';
          }
  
          return $url;
      }
code: public static function normalize($url = '/')
      {
          if (is_array($url)) {
              $url = static::url($url);
          }
          if (preg_match('/^[a-z\-]+:\/\//', $url)) {
              return $url;
          }
          $request = static::getRequest();
  
          if ($request) {
              $base = $request->getAttribute('base');
              if (strlen($base) && stristr($url, $base)) {
                  $url = preg_replace('/^' . preg_quote($base, '/') . '/', '', $url, 1);
              }
          }
          $url = '/' . $url;
  
          while (strpos($url, '//') !== false) {
              $url = str_replace('//', '/', $url);
          }
          $url = preg_replace('/(?:(\/$))/', '', $url);
  
          if (empty($url)) {
              return '/';
          }
  
          return $url;
      }
code_tokens: public static function normalize ( $ url = '/' ) { if ( is_array ( $ url ) ) { $ url = static :: url ( $ url ) ; } if ( preg_match ( '/^[a-z\-]+:\/\//' , $ url ) ) { return $ url ; } $ request = static :: getRequest ( ) ; if ( $ request ) { $ base = $ request -> getAttribute ( 'base' ) ; if ( strlen ( $ base ) && stristr ( $ url , $ base ) ) { $ url = preg_replace ( '/^' . preg_quote ( $ base , '/' ) . '/' , '' , $ url , 1 ) ; } } $ url = '/' . $ url ; while ( strpos ( $ url , '//' ) !== false ) { $ url = str_replace ( '//' , '/' , $ url ) ; } $ url = preg_replace ( '/(?:(\/$))/' , '' , $ url ) ; if ( empty ( $ url ) ) { return '/' ; } return $ url ; }
docstring: Normalizes a URL for purposes of comparison.
  
  Will strip the base path off and replace any double /'s.
  It will not unify the casing and underscoring of the input value.
  
  @param array|string $url URL to normalize Either an array or a string URL.
  @return string Normalized URL
docstring_tokens: Normalizes a URL for purposes of comparison .