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

Unified Diff: url/gurl.cc

Issue 23460053: Allow tail to not be trimmed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « url/gurl.h ('k') | url/gurl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/gurl.cc
diff --git a/url/gurl.cc b/url/gurl.cc
index 229df5dca2dbd6d1ab3de26c96d4d3afca49b60b..c2b9c50467e80703adcb911c982db8b6746a11a5 100644
--- a/url/gurl.cc
+++ b/url/gurl.cc
@@ -25,14 +25,15 @@ namespace {
template<typename STR>
bool InitCanonical(const STR& input_spec,
std::string* canonical,
- url_parse::Parsed* parsed) {
+ url_parse::Parsed* parsed,
+ bool trim_tail = true) {
// Reserve enough room in the output for the input, plus some extra so that
// we have room if we have to escape a few things without reallocating.
canonical->reserve(input_spec.size() + 32);
url_canon::StdStringCanonOutput output(canonical);
bool success = url_util::Canonicalize(
input_spec.data(), static_cast<int>(input_spec.length()),
- NULL, &output, parsed);
+ NULL, &output, parsed, trim_tail);
output.Complete(); // Must be done before using string.
return success;
@@ -110,6 +111,15 @@ GURL::GURL(const base::string16& url_string) : inner_url_(NULL) {
}
}
+GURL::GURL(const std::string& url_string, TrimInputControl trim)
+ : inner_url_(NULL) {
+ is_valid_ = InitCanonical(url_string, &spec_, &parsed_, false);
+ if (is_valid_ && SchemeIsFileSystem()) {
+ inner_url_ =
+ new GURL(spec_.data(), parsed_.Length(), *parsed_.inner_parsed(), true);
+ }
+}
+
GURL::GURL(const char* canonical_spec, size_t canonical_spec_len,
const url_parse::Parsed& parsed, bool is_valid)
: spec_(canonical_spec, canonical_spec_len),
@@ -146,11 +156,11 @@ void GURL::InitializeFromCanonicalSpec() {
// We can't do this check on the inner_url of a filesystem URL, as
// canonical_spec actually points to the start of the outer URL, so we'd
// end up with infinite recursion in this constructor.
- GURL test_url(spec_);
+ GURL test_url(spec_, NO_TRIM_TAIL);
DCHECK(test_url.is_valid_ == is_valid_);
- DCHECK(test_url.spec_ == spec_);
+ DCHECK_EQ(test_url.spec_, spec_);
DCHECK(test_url.parsed_.scheme == parsed_.scheme);
DCHECK(test_url.parsed_.username == parsed_.username);
DCHECK(test_url.parsed_.password == parsed_.password);
« no previous file with comments | « url/gurl.h ('k') | url/gurl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698