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 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 UnescapeRule::Type flags = | 425 UnescapeRule::Type flags = |
426 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS; | 426 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS; |
427 *username = UnescapeAndDecodeUTF8URLComponent(url.username(), flags); | 427 *username = UnescapeAndDecodeUTF8URLComponent(url.username(), flags); |
428 *password = UnescapeAndDecodeUTF8URLComponent(url.password(), flags); | 428 *password = UnescapeAndDecodeUTF8URLComponent(url.password(), flags); |
429 } | 429 } |
430 | 430 |
431 std::string GetHostOrSpecFromURL(const GURL& url) { | 431 std::string GetHostOrSpecFromURL(const GURL& url) { |
432 return url.has_host() ? TrimEndingDot(url.host()) : url.spec(); | 432 return url.has_host() ? TrimEndingDot(url.host()) : url.spec(); |
433 } | 433 } |
434 | 434 |
| 435 bool CanStripTrailingSlash(const GURL& url) { |
| 436 // Omit the path only for standard, non-file URLs with nothing but "/" after |
| 437 // the hostname. |
| 438 return url.IsStandard() && !url.SchemeIsFile() && |
| 439 !url.SchemeIsFileSystem() && !url.has_query() && !url.has_ref() |
| 440 && url.path() == "/"; |
| 441 } |
| 442 |
435 GURL SimplifyUrlForRequest(const GURL& url) { | 443 GURL SimplifyUrlForRequest(const GURL& url) { |
436 DCHECK(url.is_valid()); | 444 DCHECK(url.is_valid()); |
437 GURL::Replacements replacements; | 445 GURL::Replacements replacements; |
438 replacements.ClearUsername(); | 446 replacements.ClearUsername(); |
439 replacements.ClearPassword(); | 447 replacements.ClearPassword(); |
440 replacements.ClearRef(); | 448 replacements.ClearRef(); |
441 return url.ReplaceComponents(replacements); | 449 return url.ReplaceComponents(replacements); |
442 } | 450 } |
443 | 451 |
444 bool HaveOnlyLoopbackAddresses() { | 452 bool HaveOnlyLoopbackAddresses() { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 }; | 631 }; |
624 const std::string& host = url.host(); | 632 const std::string& host = url.host(); |
625 for (const char* suffix : kGoogleHostSuffixes) { | 633 for (const char* suffix : kGoogleHostSuffixes) { |
626 if (base::EndsWith(host, suffix, base::CompareCase::INSENSITIVE_ASCII)) | 634 if (base::EndsWith(host, suffix, base::CompareCase::INSENSITIVE_ASCII)) |
627 return true; | 635 return true; |
628 } | 636 } |
629 return false; | 637 return false; |
630 } | 638 } |
631 | 639 |
632 } // namespace net | 640 } // namespace net |
OLD | NEW |