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); |