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

Side by Side Diff: net/base/net_util.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 <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } else if (!IsHostCharAlphanumeric(c) && (c != '-') && (c != '_')) { 272 } else if (!IsHostCharAlphanumeric(c) && (c != '-') && (c != '_')) {
273 return false; 273 return false;
274 } 274 }
275 } 275 }
276 276
277 return most_recent_component_started_alphanumeric; 277 return most_recent_component_started_alphanumeric;
278 } 278 }
279 279
280 base::string16 StripWWW(const base::string16& text) { 280 base::string16 StripWWW(const base::string16& text) {
281 const base::string16 www(base::ASCIIToUTF16("www.")); 281 const base::string16 www(base::ASCIIToUTF16("www."));
282 return base::StartsWith(text, www, true) ? text.substr(www.length()) : text; 282 return base::StartsWith(text, www, base::CompareCase::INSENSITIVE_ASCII)
sky 2015/07/01 03:18:28 It seems right that this code is insensitive, yet
brettw 2015/07/01 16:54:26 This was a mistake, I didn't mean to change it. I
283 ? text.substr(www.length()) : text;
283 } 284 }
284 285
285 base::string16 StripWWWFromHost(const GURL& url) { 286 base::string16 StripWWWFromHost(const GURL& url) {
286 DCHECK(url.is_valid()); 287 DCHECK(url.is_valid());
287 return StripWWW(base::ASCIIToUTF16(url.host())); 288 return StripWWW(base::ASCIIToUTF16(url.host()));
288 } 289 }
289 290
290 bool IsPortValid(int port) { 291 bool IsPortValid(int port) {
291 return port >= 0 && port <= std::numeric_limits<uint16_t>::max(); 292 return port >= 0 && port <= std::numeric_limits<uint16_t>::max();
292 } 293 }
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 }; 832 };
832 const std::string& host = url.host(); 833 const std::string& host = url.host();
833 for (const char* suffix : kGoogleHostSuffixes) { 834 for (const char* suffix : kGoogleHostSuffixes) {
834 if (base::EndsWith(host, suffix, false)) 835 if (base::EndsWith(host, suffix, false))
835 return true; 836 return true;
836 } 837 }
837 return false; 838 return false;
838 } 839 }
839 840
840 } // namespace net 841 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698