OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 {"omit http with https", | 634 {"omit http with https", |
635 "https://www.google.com/", "en", kFormatUrlOmitHTTP, | 635 "https://www.google.com/", "en", kFormatUrlOmitHTTP, |
636 UnescapeRule::NORMAL, L"https://www.google.com/", | 636 UnescapeRule::NORMAL, L"https://www.google.com/", |
637 8}, | 637 8}, |
638 | 638 |
639 {"omit http starts with ftp.", | 639 {"omit http starts with ftp.", |
640 "http://ftp.google.com/", "en", kFormatUrlOmitHTTP, | 640 "http://ftp.google.com/", "en", kFormatUrlOmitHTTP, |
641 UnescapeRule::NORMAL, L"http://ftp.google.com/", | 641 UnescapeRule::NORMAL, L"http://ftp.google.com/", |
642 7}, | 642 7}, |
643 | 643 |
| 644 // -------- omit default port -------- |
| 645 {"handle no port to begin with", |
| 646 "http://www.google.com/", "en", |
| 647 kFormatUrlOmitDefaultPort, UnescapeRule::NORMAL, |
| 648 L"http://www.google.com/", 7}, |
| 649 {"omit default port for http -> 80", |
| 650 "http://www.google.com:80/", "en", |
| 651 kFormatUrlOmitDefaultPort, UnescapeRule::NORMAL, |
| 652 L"http://www.google.com/", 7}, |
| 653 {"leave port for http -> 81", |
| 654 "http://www.google.com:81/", "en", |
| 655 kFormatUrlOmitDefaultPort, UnescapeRule::NORMAL, |
| 656 L"http://www.google.com:81/", 7}, |
| 657 {"omit port for https -> 443", |
| 658 "https://www.google.com:443/", "en", |
| 659 kFormatUrlOmitDefaultPort, UnescapeRule::NORMAL, |
| 660 L"https://www.google.com/", 8}, |
| 661 {"leave port for https -> 80", |
| 662 "https://www.google.com:80/", "en", |
| 663 kFormatUrlOmitDefaultPort, UnescapeRule::NORMAL, |
| 664 L"https://www.google.com:80/", 8}, |
| 665 {"omit port for ftp -> 21", |
| 666 "ftp://www.google.com:21/", "en", |
| 667 kFormatUrlOmitDefaultPort, UnescapeRule::NORMAL, |
| 668 L"ftp://www.google.com/", 6}, |
| 669 {"leave port for ftp -> 40", |
| 670 "ftp://www.google.com:40/", "en", |
| 671 kFormatUrlOmitDefaultPort, UnescapeRule::NORMAL, |
| 672 L"ftp://www.google.com:40/", 6}, |
| 673 |
644 // -------- omit trailing slash on bare hostname -------- | 674 // -------- omit trailing slash on bare hostname -------- |
645 {"omit slash when it's the entire path", | 675 {"omit slash when it's the entire path", |
646 "http://www.google.com/", "en", | 676 "http://www.google.com/", "en", |
647 kFormatUrlOmitTrailingSlashOnBareHostname, UnescapeRule::NORMAL, | 677 kFormatUrlOmitTrailingSlashOnBareHostname, UnescapeRule::NORMAL, |
648 L"http://www.google.com", 7}, | 678 L"http://www.google.com", 7}, |
649 {"omit slash when there's a ref", | 679 {"omit slash when there's a ref", |
650 "http://www.google.com/#ref", "en", | 680 "http://www.google.com/#ref", "en", |
651 kFormatUrlOmitTrailingSlashOnBareHostname, UnescapeRule::NORMAL, | 681 kFormatUrlOmitTrailingSlashOnBareHostname, UnescapeRule::NORMAL, |
652 L"http://www.google.com/#ref", 7}, | 682 L"http://www.google.com/#ref", 7}, |
653 {"omit slash when there's a query", | 683 {"omit slash when there's a query", |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 | 1092 |
1063 const size_t omit_all_offsets[] = { | 1093 const size_t omit_all_offsets[] = { |
1064 0, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 0, kNpos, kNpos, kNpos, kNpos, | 1094 0, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 0, kNpos, kNpos, kNpos, kNpos, |
1065 0, 1, 2, 3, 4, 5, 6, 7 | 1095 0, 1, 2, 3, 4, 5, 6, 7 |
1066 }; | 1096 }; |
1067 CheckAdjustedOffsets("http://user@foo.com/", "en", kFormatUrlOmitAll, | 1097 CheckAdjustedOffsets("http://user@foo.com/", "en", kFormatUrlOmitAll, |
1068 UnescapeRule::NORMAL, omit_all_offsets); | 1098 UnescapeRule::NORMAL, omit_all_offsets); |
1069 } | 1099 } |
1070 | 1100 |
1071 } // namespace net | 1101 } // namespace net |
OLD | NEW |