Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/url_formatter/url_formatter.h" | 5 #include "components/url_formatter/url_formatter.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 831 {"omit http", "http://www.google.com/", kFormatUrlOmitHTTP, | 831 {"omit http", "http://www.google.com/", kFormatUrlOmitHTTP, |
| 832 net::UnescapeRule::NORMAL, L"www.google.com/", 0}, | 832 net::UnescapeRule::NORMAL, L"www.google.com/", 0}, |
| 833 | 833 |
| 834 {"omit http with https", "https://www.google.com/", kFormatUrlOmitHTTP, | 834 {"omit http with https", "https://www.google.com/", kFormatUrlOmitHTTP, |
| 835 net::UnescapeRule::NORMAL, L"https://www.google.com/", 8}, | 835 net::UnescapeRule::NORMAL, L"https://www.google.com/", 8}, |
| 836 | 836 |
| 837 {"omit http starts with ftp.", "http://ftp.google.com/", | 837 {"omit http starts with ftp.", "http://ftp.google.com/", |
| 838 kFormatUrlOmitHTTP, net::UnescapeRule::NORMAL, L"http://ftp.google.com/", | 838 kFormatUrlOmitHTTP, net::UnescapeRule::NORMAL, L"http://ftp.google.com/", |
| 839 7}, | 839 7}, |
| 840 | 840 |
| 841 // -------- omit https -------- | |
|
Peter Kasting
2017/06/28 23:09:59
I kinda feel like this block should go after your
tommycli
2017/06/29 00:19:43
Done.
| |
| 842 {"omit https", "http://www.google.com/", | |
|
Peter Kasting
2017/06/28 23:09:59
This URL uses HTTP and not HTTPS, so it doesn't te
tommycli
2017/06/29 00:19:43
Done.
| |
| 843 kFormatUrlOmitHTTP | kFormatUrlExperimentalOmitHTTPS, | |
|
Peter Kasting
2017/06/28 23:09:59
Seems like we don't need (or, honestly, want) to p
tommycli
2017/06/29 00:19:43
Done.
Also testing username/password eliding to v
| |
| 844 net::UnescapeRule::NORMAL, L"www.google.com/", 0}, | |
| 845 | |
| 846 {"omit https with user name", "https://user@example.com/foo", | |
| 847 kFormatUrlOmitAll | kFormatUrlExperimentalOmitHTTPS, | |
| 848 net::UnescapeRule::NORMAL, L"example.com/foo", 0}, | |
| 849 | |
| 850 {"omit https with user name and password", | |
| 851 "https://user:password@example.com/foo", | |
| 852 kFormatUrlOmitAll | kFormatUrlExperimentalOmitHTTPS, | |
| 853 net::UnescapeRule::NORMAL, L"example.com/foo", 0}, | |
| 854 | |
| 855 {"omit https should not affect hosts starting with ftp.", | |
| 856 "https://ftp.google.com/", | |
| 857 kFormatUrlOmitHTTP | kFormatUrlExperimentalOmitHTTPS, | |
| 858 net::UnescapeRule::NORMAL, L"https://ftp.google.com/", 8}, | |
| 859 | |
| 841 // -------- omit trailing slash on bare hostname -------- | 860 // -------- omit trailing slash on bare hostname -------- |
| 842 {"omit slash when it's the entire path", "http://www.google.com/", | 861 {"omit slash when it's the entire path", "http://www.google.com/", |
| 843 kFormatUrlOmitTrailingSlashOnBareHostname, net::UnescapeRule::NORMAL, | 862 kFormatUrlOmitTrailingSlashOnBareHostname, net::UnescapeRule::NORMAL, |
| 844 L"http://www.google.com", 7}, | 863 L"http://www.google.com", 7}, |
| 845 {"omit slash when there's a ref", "http://www.google.com/#ref", | 864 {"omit slash when there's a ref", "http://www.google.com/#ref", |
| 846 kFormatUrlOmitTrailingSlashOnBareHostname, net::UnescapeRule::NORMAL, | 865 kFormatUrlOmitTrailingSlashOnBareHostname, net::UnescapeRule::NORMAL, |
| 847 L"http://www.google.com/#ref", 7}, | 866 L"http://www.google.com/#ref", 7}, |
| 848 {"omit slash when there's a query", "http://www.google.com/?", | 867 {"omit slash when there's a query", "http://www.google.com/?", |
| 849 kFormatUrlOmitTrailingSlashOnBareHostname, net::UnescapeRule::NORMAL, | 868 kFormatUrlOmitTrailingSlashOnBareHostname, net::UnescapeRule::NORMAL, |
| 850 L"http://www.google.com/?", 7}, | 869 L"http://www.google.com/?", 7}, |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1242 CheckAdjustedOffsets("http://www.google.com/", kFormatUrlOmitHTTP, | 1261 CheckAdjustedOffsets("http://www.google.com/", kFormatUrlOmitHTTP, |
| 1243 net::UnescapeRule::NORMAL, omit_http_offsets); | 1262 net::UnescapeRule::NORMAL, omit_http_offsets); |
| 1244 | 1263 |
| 1245 const size_t omit_http_start_with_ftp_offsets[] = { | 1264 const size_t omit_http_start_with_ftp_offsets[] = { |
| 1246 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 | 1265 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 |
| 1247 }; | 1266 }; |
| 1248 CheckAdjustedOffsets("http://ftp.google.com/", kFormatUrlOmitHTTP, | 1267 CheckAdjustedOffsets("http://ftp.google.com/", kFormatUrlOmitHTTP, |
| 1249 net::UnescapeRule::NORMAL, | 1268 net::UnescapeRule::NORMAL, |
| 1250 omit_http_start_with_ftp_offsets); | 1269 omit_http_start_with_ftp_offsets); |
| 1251 | 1270 |
| 1271 const size_t omit_https_offsets[] = { | |
| 1272 0, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 0, 1, 2, 3, | |
| 1273 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; | |
| 1274 CheckAdjustedOffsets("https://www.google.com/", | |
| 1275 kFormatUrlExperimentalOmitHTTPS, | |
| 1276 net::UnescapeRule::NORMAL, omit_https_offsets); | |
| 1277 | |
| 1278 const size_t omit_https_with_auth_offsets[] = { | |
| 1279 0, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 0, | |
| 1280 kNpos, kNpos, kNpos, 0, 1, 2, 3, 4, 5, | |
| 1281 6, 7, 8, 9, 10, 11, 12, 13, 14}; | |
| 1282 CheckAdjustedOffsets("https://u:p@www.google.com/", | |
| 1283 kFormatUrlOmitAll | kFormatUrlExperimentalOmitHTTPS, | |
| 1284 net::UnescapeRule::NORMAL, omit_https_with_auth_offsets); | |
| 1285 | |
| 1252 const size_t omit_all_offsets[] = { | 1286 const size_t omit_all_offsets[] = { |
| 1253 0, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 0, kNpos, kNpos, kNpos, kNpos, | 1287 0, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 0, kNpos, kNpos, kNpos, kNpos, |
| 1254 0, 1, 2, 3, 4, 5, 6, 7 | 1288 0, 1, 2, 3, 4, 5, 6, 7 |
| 1255 }; | 1289 }; |
| 1256 CheckAdjustedOffsets("http://user@foo.com/", kFormatUrlOmitAll, | 1290 CheckAdjustedOffsets("http://user@foo.com/", kFormatUrlOmitAll, |
| 1257 net::UnescapeRule::NORMAL, omit_all_offsets); | 1291 net::UnescapeRule::NORMAL, omit_all_offsets); |
| 1258 | 1292 |
| 1259 const size_t elide_after_host_offsets[] = { | 1293 const size_t elide_after_host_offsets[] = { |
| 1260 0, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 0, 1, 2, 3, 4, | 1294 0, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 0, 1, 2, 3, 4, |
| 1261 5, 6, 7, 8, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 9}; | 1295 5, 6, 7, 8, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 9}; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1275 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, | 1309 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, |
| 1276 net::UnescapeRule::NORMAL, elide_after_host_offsets); | 1310 net::UnescapeRule::NORMAL, elide_after_host_offsets); |
| 1277 CheckAdjustedOffsets("http://foo.com//??###", | 1311 CheckAdjustedOffsets("http://foo.com//??###", |
| 1278 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, | 1312 kFormatUrlOmitAll | kFormatUrlExperimentalElideAfterHost, |
| 1279 net::UnescapeRule::NORMAL, elide_after_host_offsets); | 1313 net::UnescapeRule::NORMAL, elide_after_host_offsets); |
| 1280 } | 1314 } |
| 1281 | 1315 |
| 1282 } // namespace | 1316 } // namespace |
| 1283 | 1317 |
| 1284 } // namespace url_formatter | 1318 } // namespace url_formatter |
| OLD | NEW |