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

Unified Diff: url/gurl.cc

Issue 2562813003: Merge logic for SameDomainOrHost for GURLs and Origins (Closed)
Patch Set: brettw review Created 4 years 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 | « net/base/registry_controlled_domains/registry_controlled_domain.cc ('k') | url/url_util.h » ('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 bdd35227b0dadbd36024a12aa5f51799c189ec06..c0e4a68c3fca08250c5fd21e46e234189d8c5c1f 100644
--- a/url/gurl.cc
+++ b/url/gurl.cc
@@ -121,6 +121,8 @@ void GURL::InitCanonical(base::BasicStringPiece<STR> input_spec,
inner_url_.reset(new GURL(spec_.data(), parsed_.Length(),
*parsed_.inner_parsed(), true));
}
+ // Valid URLs always have non-empty specs.
+ DCHECK(!is_valid_ || !spec_.empty());
}
void GURL::InitializeFromCanonicalSpec() {
@@ -135,6 +137,7 @@ void GURL::InitializeFromCanonicalSpec() {
// what we would have produced. Skip checking for invalid URLs have no meaning
// and we can't always canonicalize then reproducibly.
if (is_valid_) {
+ DCHECK(!spec_.empty());
url::Component scheme;
// 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
@@ -440,14 +443,7 @@ std::string GURL::GetContent() const {
}
bool GURL::HostIsIPAddress() const {
- if (!is_valid_ || spec_.empty())
- return false;
-
- url::RawCanonOutputT<char, 128> ignored_output;
- url::CanonHostInfo host_info;
- url::CanonicalizeIPAddress(spec_.c_str(), parsed_.host, &ignored_output,
- &host_info);
- return host_info.IsIPAddress();
+ return is_valid_ && url::HostIsIPAddress(host_piece());
}
#ifdef WIN32
« no previous file with comments | « net/base/registry_controlled_domains/registry_controlled_domain.cc ('k') | url/url_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698