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

Unified Diff: url/gurl.cc

Issue 2287483002: Provide the equivalent of GURL::DomainIs for url::Origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | url/origin.h » ('j') | url/origin_unittest.cc » ('J')
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 2c8f3f5612e3d81e03711168b6fd162709612853..34bf867037d13660bab1cfa5b0814de9afffe3d1 100644
--- a/url/gurl.cc
+++ b/url/gurl.cc
@@ -498,40 +498,8 @@ bool GURL::DomainIs(base::StringPiece lower_ascii_domain) const {
if (SchemeIsFileSystem() && inner_url_)
return inner_url_->DomainIs(lower_ascii_domain);
- if (!parsed_.host.is_nonempty())
- return false;
-
- // If the host name ends with a dot but the input domain doesn't,
- // then we ignore the dot in the host name.
- const char* host_last_pos = spec_.data() + parsed_.host.end() - 1;
- int host_len = parsed_.host.len;
- int domain_len = lower_ascii_domain.length();
- if ('.' == *host_last_pos && '.' != lower_ascii_domain[domain_len - 1]) {
- host_last_pos--;
- host_len--;
- }
-
- if (host_len < domain_len)
- return false;
-
- // |host_first_pos| is the start of the compared part of the host name, not
- // start of the whole host name.
- const char* host_first_pos = spec_.data() + parsed_.host.begin +
- host_len - domain_len;
-
- if (!base::LowerCaseEqualsASCII(
- base::StringPiece(host_first_pos, domain_len), lower_ascii_domain))
- return false;
-
- // Make sure there aren't extra characters in host before the compared part;
- // if the host name is longer than the input domain name, then the character
- // immediately before the compared part should be a dot. For example,
- // www.google.com has domain "google.com", but www.iamnotgoogle.com does not.
- if ('.' != lower_ascii_domain[0] && host_len > domain_len &&
- '.' != *(host_first_pos - 1))
- return false;
-
- return true;
+ return parsed_.host.is_nonempty() &&
+ url::DomainIs(host_piece(), lower_ascii_domain);
}
void GURL::Swap(GURL* other) {
« no previous file with comments | « no previous file | url/origin.h » ('j') | url/origin_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698