Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: src/url_canon_relative.cc

Issue 600087: When resolving URL, empty relative URL should remove ref component.... (Closed) Base URL: http://google-url.googlecode.com/svn/trunk/
Patch Set: Changed to use Append. Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/url_canon_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007, Google Inc. 1 // Copyright 2007, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 if (base_parsed.path.len <= 0) { 450 if (base_parsed.path.len <= 0) {
451 // On error, return the input (resolving a relative URL on a non-relative 451 // On error, return the input (resolving a relative URL on a non-relative
452 // base = the base). 452 // base = the base).
453 int base_len = base_parsed.Length(); 453 int base_len = base_parsed.Length();
454 for (int i = 0; i < base_len; i++) 454 for (int i = 0; i < base_len; i++)
455 output->push_back(base_url[i]); 455 output->push_back(base_url[i]);
456 return false; 456 return false;
457 } 457 }
458 458
459 if (relative_component.len <= 0) { 459 if (relative_component.len <= 0) {
460 // Empty relative URL, make no changes. 460 // Empty relative URL, leave unchanged, only removing the ref component.
461 int base_len = base_parsed.Length(); 461 int base_len = base_parsed.Length();
462 for (int i = 0; i < base_len; i++) 462 base_len -= base_parsed.ref.len + 1;
463 output->push_back(base_url[i]); 463 out_parsed->ref.reset();
464 output->Append(base_url, base_len);
464 return true; 465 return true;
465 } 466 }
466 467
467 int num_slashes = url_parse::CountConsecutiveSlashes( 468 int num_slashes = url_parse::CountConsecutiveSlashes(
468 relative_url, relative_component.begin, relative_component.end()); 469 relative_url, relative_component.begin, relative_component.end());
469 470
470 #ifdef WIN32 471 #ifdef WIN32
471 // On Windows, two slashes for a file path (regardless of which direction 472 // On Windows, two slashes for a file path (regardless of which direction
472 // they are) means that it's UNC. Two backslashes on any base scheme mean 473 // they are) means that it's UNC. Two backslashes on any base scheme mean
473 // that it's an absolute UNC path (we use the base_is_file flag to control 474 // that it's an absolute UNC path (we use the base_is_file flag to control
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 const url_parse::Component& relative_component, 563 const url_parse::Component& relative_component,
563 CharsetConverter* query_converter, 564 CharsetConverter* query_converter,
564 CanonOutput* output, 565 CanonOutput* output,
565 url_parse::Parsed* out_parsed) { 566 url_parse::Parsed* out_parsed) {
566 return DoResolveRelativeURL<char16>( 567 return DoResolveRelativeURL<char16>(
567 base_url, base_parsed, base_is_file, relative_url, 568 base_url, base_parsed, base_is_file, relative_url,
568 relative_component, query_converter, output, out_parsed); 569 relative_component, query_converter, output, out_parsed);
569 } 570 }
570 571
571 } // namespace url_canon 572 } // namespace url_canon
OLDNEW
« no previous file with comments | « no previous file | src/url_canon_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698