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 "net/base/url_util.h" | 5 #include "net/base/url_util.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 {GURL("http://google.co"), false}, | 575 {GURL("http://google.co"), false}, |
576 {GURL("http://oggole.com"), false}, | 576 {GURL("http://oggole.com"), false}, |
577 }; | 577 }; |
578 | 578 |
579 for (size_t i = 0; i < arraysize(google_host_cases); ++i) { | 579 for (size_t i = 0; i < arraysize(google_host_cases); ++i) { |
580 EXPECT_EQ(google_host_cases[i].expected_output, | 580 EXPECT_EQ(google_host_cases[i].expected_output, |
581 HasGoogleHost(google_host_cases[i].url)); | 581 HasGoogleHost(google_host_cases[i].url)); |
582 } | 582 } |
583 } | 583 } |
584 | 584 |
| 585 TEST(UrlUtilTest, IsDomainMatch) { |
| 586 GURL url("http://www.example.com/test/foo.html"); |
| 587 |
| 588 std::string domain = "www.example.com"; |
| 589 EXPECT_TRUE(IsDomainMatch(domain, "www.example.com")); |
| 590 EXPECT_FALSE(IsDomainMatch(domain, "foo.www.example.com")); |
| 591 EXPECT_FALSE(IsDomainMatch(domain, "www0.example.com")); |
| 592 EXPECT_FALSE(IsDomainMatch(domain, "example.com")); |
| 593 |
| 594 domain = ".www.example.com"; |
| 595 EXPECT_TRUE(IsDomainMatch(domain, "www.example.com")); |
| 596 EXPECT_TRUE(IsDomainMatch(domain, "www.example.com")); |
| 597 EXPECT_TRUE(IsDomainMatch(domain, "foo.www.example.com")); |
| 598 EXPECT_FALSE(IsDomainMatch(domain, "www0.example.com")); |
| 599 EXPECT_FALSE(IsDomainMatch(domain, "example.com")); |
| 600 } |
| 601 |
585 } // namespace | 602 } // namespace |
586 } // namespace net | 603 } // namespace net |
OLD | NEW |