OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/net_util.h" | 5 #include "net/base/net_util.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 } else if (!IsHostCharAlphanumeric(c) && (c != '-') && (c != '_')) { | 272 } else if (!IsHostCharAlphanumeric(c) && (c != '-') && (c != '_')) { |
273 return false; | 273 return false; |
274 } | 274 } |
275 } | 275 } |
276 | 276 |
277 return most_recent_component_started_alphanumeric; | 277 return most_recent_component_started_alphanumeric; |
278 } | 278 } |
279 | 279 |
280 base::string16 StripWWW(const base::string16& text) { | 280 base::string16 StripWWW(const base::string16& text) { |
281 const base::string16 www(base::ASCIIToUTF16("www.")); | 281 const base::string16 www(base::ASCIIToUTF16("www.")); |
282 return base::StartsWith(text, www, true) ? text.substr(www.length()) : text; | 282 return base::StartsWith(text, www, base::CompareCase::SENSITIVE) |
| 283 ? text.substr(www.length()) : text; |
283 } | 284 } |
284 | 285 |
285 base::string16 StripWWWFromHost(const GURL& url) { | 286 base::string16 StripWWWFromHost(const GURL& url) { |
286 DCHECK(url.is_valid()); | 287 DCHECK(url.is_valid()); |
287 return StripWWW(base::ASCIIToUTF16(url.host())); | 288 return StripWWW(base::ASCIIToUTF16(url.host())); |
288 } | 289 } |
289 | 290 |
290 bool IsPortValid(int port) { | 291 bool IsPortValid(int port) { |
291 return port >= 0 && port <= std::numeric_limits<uint16_t>::max(); | 292 return port >= 0 && port <= std::numeric_limits<uint16_t>::max(); |
292 } | 293 } |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 }; | 832 }; |
832 const std::string& host = url.host(); | 833 const std::string& host = url.host(); |
833 for (const char* suffix : kGoogleHostSuffixes) { | 834 for (const char* suffix : kGoogleHostSuffixes) { |
834 if (base::EndsWith(host, suffix, false)) | 835 if (base::EndsWith(host, suffix, false)) |
835 return true; | 836 return true; |
836 } | 837 } |
837 return false; | 838 return false; |
838 } | 839 } |
839 | 840 |
840 } // namespace net | 841 } // namespace net |
OLD | NEW |