Chromium Code Reviews| 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 "chrome/common/extensions/url_pattern.h" | 5 #include "chrome/common/extensions/url_pattern.h" |
| 6 | 6 |
| 7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/string_piece.h" | 8 #include "base/string_piece.h" |
| 9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 return false; | 371 return false; |
| 372 | 372 |
| 373 if (test.host().compare(test.host().length() - host_.length(), | 373 if (test.host().compare(test.host().length() - host_.length(), |
| 374 host_.length(), host_) != 0) | 374 host_.length(), host_) != 0) |
| 375 return false; | 375 return false; |
| 376 | 376 |
| 377 return test.host()[test.host().length() - host_.length() - 1] == '.'; | 377 return test.host()[test.host().length() - host_.length() - 1] == '.'; |
| 378 } | 378 } |
| 379 | 379 |
| 380 bool URLPattern::MatchesPath(const std::string& test) const { | 380 bool URLPattern::MatchesPath(const std::string& test) const { |
| 381 if (!MatchPattern(test, path_escaped_)) | 381 return MatchPattern(test, path_escaped_) || |
| 382 return false; | 382 MatchPattern(test + '/', path_escaped_) || |
| 383 | 383 MatchPattern(test, path_escaped_ + '/'); |
|
jstritar
2012/04/22 17:57:31
I did this because some apps, like Google Finance,
miket_OOO
2012/04/23 22:11:16
I'd prefer to force developers to get it exactly r
jstritar
2012/04/23 23:46:12
Agreed... if we do any fuzzy matching it probably
| |
| 384 return true; | |
| 385 } | 384 } |
| 386 | 385 |
| 387 bool URLPattern::MatchesPort(int port) const { | 386 bool URLPattern::MatchesPort(int port) const { |
| 388 if (port == url_parse::PORT_INVALID) | 387 if (port == url_parse::PORT_INVALID) |
| 389 return false; | 388 return false; |
| 390 | 389 |
| 391 return port_ == "*" || port_ == base::IntToString(port); | 390 return port_ == "*" || port_ == base::IntToString(port); |
| 392 } | 391 } |
| 393 | 392 |
| 394 | 393 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 512 } | 511 } |
| 513 | 512 |
| 514 return result; | 513 return result; |
| 515 } | 514 } |
| 516 | 515 |
| 517 // static | 516 // static |
| 518 const char* URLPattern::GetParseResultString( | 517 const char* URLPattern::GetParseResultString( |
| 519 URLPattern::ParseResult parse_result) { | 518 URLPattern::ParseResult parse_result) { |
| 520 return kParseResultMessages[parse_result]; | 519 return kParseResultMessages[parse_result]; |
| 521 } | 520 } |
| OLD | NEW |