Chromium Code Reviews| Index: content/browser/service_worker/service_worker_utils.cc |
| diff --git a/content/browser/service_worker/service_worker_utils.cc b/content/browser/service_worker/service_worker_utils.cc |
| index e05c546d73d1ba9f28d991d9dbca3068282054f6..757a6e71d03f5b431590d19b9deb49921a62e0b0 100644 |
| --- a/content/browser/service_worker/service_worker_utils.cc |
| +++ b/content/browser/service_worker/service_worker_utils.cc |
| @@ -5,7 +5,6 @@ |
| #include "content/browser/service_worker/service_worker_utils.h" |
| #include "base/command_line.h" |
| -#include "base/strings/string_util.h" |
| #include "content/public/common/content_switches.h" |
| namespace content { |
| @@ -19,15 +18,12 @@ bool ServiceWorkerUtils::IsFeatureEnabled() { |
| // static |
| bool ServiceWorkerUtils::ScopeMatches(const GURL& scope, const GURL& url) { |
| - // This is a really basic, naive |
| - // TODO(alecflett): Formalize what scope matches mean. |
| - // Temporarily borrowed directly from appcache::Namespace::IsMatch(). |
| - // We have to escape '?' characters since MatchPattern also treats those |
| - // as wildcards which we don't want here, we only do '*'s. |
| - std::string scope_spec(scope.spec()); |
| - if (scope.has_query()) |
| - ReplaceSubstringsAfterOffset(&scope_spec, 0, "?", "\\?"); |
| - return MatchPattern(url.spec(), scope_spec); |
| + const std::string scope_spec(scope.spec()); |
|
falken
2014/05/14 14:51:30
can it just be const std::string& scope_spec = sco
jsbell
2014/05/14 20:31:38
Cool, yes it can! Done.
|
| + size_t len = scope_spec.size(); |
| + if (len > 0 && scope_spec[len - 1] == '*') { |
| + return scope_spec.compare(0, len - 1, url.spec(), 0, len - 1) == 0; |
| + } |
| + return scope_spec == url.spec(); |
| } |
| } // namespace content |