Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(527)

Side by Side Diff: net/base/net_util_icu.cc

Issue 1220653002: Fix some case-insensitive cases for StartsWith (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/i18n/time_formatting.h" 10 #include "base/i18n/time_formatting.h"
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 787
788 // Ref. This is valid, unescaped UTF-8, so we can just convert. 788 // Ref. This is valid, unescaped UTF-8, so we can just convert.
789 if (parsed.ref.is_valid()) 789 if (parsed.ref.is_valid())
790 url_string.push_back('#'); 790 url_string.push_back('#');
791 AppendFormattedComponent(spec, parsed.ref, 791 AppendFormattedComponent(spec, parsed.ref,
792 NonHostComponentTransform(UnescapeRule::NONE), 792 NonHostComponentTransform(UnescapeRule::NONE),
793 &url_string, &new_parsed->ref, adjustments); 793 &url_string, &new_parsed->ref, adjustments);
794 794
795 // If we need to strip out http do it after the fact. 795 // If we need to strip out http do it after the fact.
796 if (omit_http && 796 if (omit_http &&
797 base::StartsWith(url_string, base::ASCIIToUTF16(kHTTP), true)) { 797 base::StartsWith(url_string, base::ASCIIToUTF16(kHTTP),
798 base::CompareCase::SENSITIVE)) {
798 const size_t kHTTPSize = arraysize(kHTTP) - 1; 799 const size_t kHTTPSize = arraysize(kHTTP) - 1;
799 url_string = url_string.substr(kHTTPSize); 800 url_string = url_string.substr(kHTTPSize);
800 // Because offsets in the |adjustments| are already calculated with respect 801 // Because offsets in the |adjustments| are already calculated with respect
801 // to the string with the http:// prefix in it, those offsets remain correct 802 // to the string with the http:// prefix in it, those offsets remain correct
802 // after stripping the prefix. The only thing necessary is to add an 803 // after stripping the prefix. The only thing necessary is to add an
803 // adjustment to reflect the stripped prefix. 804 // adjustment to reflect the stripped prefix.
804 adjustments->insert(adjustments->begin(), 805 adjustments->insert(adjustments->begin(),
805 base::OffsetAdjuster::Adjustment(0, kHTTPSize, 0)); 806 base::OffsetAdjuster::Adjustment(0, kHTTPSize, 0));
806 807
807 if (prefix_end) 808 if (prefix_end)
(...skipping 20 matching lines...) Expand all
828 if (offset_for_adjustment) 829 if (offset_for_adjustment)
829 offsets.push_back(*offset_for_adjustment); 830 offsets.push_back(*offset_for_adjustment);
830 base::string16 result = FormatUrlWithOffsets(url, languages, format_types, 831 base::string16 result = FormatUrlWithOffsets(url, languages, format_types,
831 unescape_rules, new_parsed, prefix_end, &offsets); 832 unescape_rules, new_parsed, prefix_end, &offsets);
832 if (offset_for_adjustment) 833 if (offset_for_adjustment)
833 *offset_for_adjustment = offsets[0]; 834 *offset_for_adjustment = offsets[0];
834 return result; 835 return result;
835 } 836 }
836 837
837 } // namespace net 838 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698