src/lib/url/url_canon_relative.cc
// Copies all characters in the range [begin, end) of |spec| to the output,
// up until and including the last slash. There should be a slash in the
// range, if not, nothing will be copied.
//
// For stardard URLs the input should be canonical, but when resolving relative
// URLs on a non-standard base (like "data:") the input can be anything.
Copies all characters in the range [begin, end) of |spec| to the output,
up until and including the last slash. There should be a slash in the
range, if not, nothing will be copied.

For stardard URLs the input should be canonical, but when resolving relative
URLs on a non-standard base (like "data:") the input can be anything.
Copies all characters in the range [ begin end ) of |spec| to the output up until and including the last slash . There should be a slash in the range if not nothing will be copied . For stardard URLs the input should be canonical but when resolving relative URLs on a non - standard base ( like " data : " ) the input can be anything .
void CopyToLastSlash(const char* spec, int begin, int end, CanonOutput* output) {
  int last_slash = -1;
  for (int i = end - 1; i >= begin; i--) {
    if (spec[i] == '/' || spec[i] == '\\') {
      last_slash = i;
      break;
    }
  }
  if (last_slash < 0)
    return;  
  for (int i = begin; i <= last_slash; i++)
    output->push_back(spec[i]);
}
void CopyToLastSlash ( const char * spec , int begin , int end , CanonOutput * output ) { int last_slash = -1 ; for ( int i = end - 1 ; i >= begin ; i -- ) { if ( spec [ i ] == ' ' || spec [ i ] == ' \\ ' ) { last_slash = i ; break ; } } if ( last_slash < 0 ) return ; for ( int i = begin ; i <= last_slash ; i ++ ) output -> push_back ( spec [ i ] ) ; }
Copies all characters in the range [begin, end) of |spec| to the output,
up until and including the last slash.
Copies all characters in the range [ begin end ) of |spec| to the output up until and including the last slash .
// Find the last slash. // No slash. // Copy.