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 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 UnescapeRule::Type flags = | 561 UnescapeRule::Type flags = |
562 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS; | 562 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS; |
563 *username = UnescapeAndDecodeUTF8URLComponent(url.username(), flags); | 563 *username = UnescapeAndDecodeUTF8URLComponent(url.username(), flags); |
564 *password = UnescapeAndDecodeUTF8URLComponent(url.password(), flags); | 564 *password = UnescapeAndDecodeUTF8URLComponent(url.password(), flags); |
565 } | 565 } |
566 | 566 |
567 std::string GetHostOrSpecFromURL(const GURL& url) { | 567 std::string GetHostOrSpecFromURL(const GURL& url) { |
568 return url.has_host() ? TrimEndingDot(url.host()) : url.spec(); | 568 return url.has_host() ? TrimEndingDot(url.host()) : url.spec(); |
569 } | 569 } |
570 | 570 |
571 bool CanStripTrailingSlash(const GURL& url) { | |
572 // Omit the path only for standard, non-file URLs with nothing but "/" after | |
573 // the hostname. | |
574 return url.IsStandard() && !url.SchemeIsFile() && | |
575 !url.SchemeIsFileSystem() && !url.has_query() && !url.has_ref() | |
576 && url.path() == "/"; | |
577 } | |
578 | |
579 GURL SimplifyUrlForRequest(const GURL& url) { | 571 GURL SimplifyUrlForRequest(const GURL& url) { |
580 DCHECK(url.is_valid()); | 572 DCHECK(url.is_valid()); |
581 GURL::Replacements replacements; | 573 GURL::Replacements replacements; |
582 replacements.ClearUsername(); | 574 replacements.ClearUsername(); |
583 replacements.ClearPassword(); | 575 replacements.ClearPassword(); |
584 replacements.ClearRef(); | 576 replacements.ClearRef(); |
585 return url.ReplaceComponents(replacements); | 577 return url.ReplaceComponents(replacements); |
586 } | 578 } |
587 | 579 |
588 // Specifies a comma separated list of port numbers that should be accepted | 580 // Specifies a comma separated list of port numbers that should be accepted |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 }; | 790 }; |
799 const std::string& host = url.host(); | 791 const std::string& host = url.host(); |
800 for (const char* suffix : kGoogleHostSuffixes) { | 792 for (const char* suffix : kGoogleHostSuffixes) { |
801 if (EndsWith(host, suffix, false)) | 793 if (EndsWith(host, suffix, false)) |
802 return true; | 794 return true; |
803 } | 795 } |
804 return false; | 796 return false; |
805 } | 797 } |
806 | 798 |
807 } // namespace net | 799 } // namespace net |
OLD | NEW |