OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "url/url_util.h" | 5 #include "url/url_util.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 // immediately before the compared part should be a dot. For example, | 531 // immediately before the compared part should be a dot. For example, |
532 // www.google.com has domain "google.com", but www.iamnotgoogle.com does not. | 532 // www.google.com has domain "google.com", but www.iamnotgoogle.com does not. |
533 if (lower_ascii_domain[0] != '.' && host_len > lower_ascii_domain.length() && | 533 if (lower_ascii_domain[0] != '.' && host_len > lower_ascii_domain.length() && |
534 *(host_first_pos - 1) != '.') { | 534 *(host_first_pos - 1) != '.') { |
535 return false; | 535 return false; |
536 } | 536 } |
537 | 537 |
538 return true; | 538 return true; |
539 } | 539 } |
540 | 540 |
| 541 bool HostIsIPAddress(base::StringPiece host) { |
| 542 url::RawCanonOutputT<char, 128> ignored_output; |
| 543 url::CanonHostInfo host_info; |
| 544 url::CanonicalizeIPAddress(host.data(), Component(0, host.length()), |
| 545 &ignored_output, &host_info); |
| 546 return host_info.IsIPAddress(); |
| 547 } |
| 548 |
541 bool Canonicalize(const char* spec, | 549 bool Canonicalize(const char* spec, |
542 int spec_len, | 550 int spec_len, |
543 bool trim_path_end, | 551 bool trim_path_end, |
544 CharsetConverter* charset_converter, | 552 CharsetConverter* charset_converter, |
545 CanonOutput* output, | 553 CanonOutput* output, |
546 Parsed* output_parsed) { | 554 Parsed* output_parsed) { |
547 return DoCanonicalize(spec, spec_len, trim_path_end, REMOVE_WHITESPACE, | 555 return DoCanonicalize(spec, spec_len, trim_path_end, REMOVE_WHITESPACE, |
548 charset_converter, output, output_parsed); | 556 charset_converter, output, output_parsed); |
549 } | 557 } |
550 | 558 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 return DoCompareSchemeComponent(spec, component, compare_to); | 680 return DoCompareSchemeComponent(spec, component, compare_to); |
673 } | 681 } |
674 | 682 |
675 bool CompareSchemeComponent(const base::char16* spec, | 683 bool CompareSchemeComponent(const base::char16* spec, |
676 const Component& component, | 684 const Component& component, |
677 const char* compare_to) { | 685 const char* compare_to) { |
678 return DoCompareSchemeComponent(spec, component, compare_to); | 686 return DoCompareSchemeComponent(spec, component, compare_to); |
679 } | 687 } |
680 | 688 |
681 } // namespace url | 689 } // namespace url |
OLD | NEW |