Index: shell/application_manager/query_util.cc |
diff --git a/shell/application_manager/query_util.cc b/shell/application_manager/query_util.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ebc12574cb0f13deafb4c6e70ad9af9c1185ea48 |
--- /dev/null |
+++ b/shell/application_manager/query_util.cc |
@@ -0,0 +1,28 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "shell/application_manager/query_util.h" |
+ |
+#include "base/strings/string_util.h" |
+ |
+namespace mojo { |
+ |
+GURL StripQueryFromURL(const GURL& url) { |
+ GURL::Replacements repl; |
+ repl.SetQueryStr(""); |
+ std::string result = url.ReplaceComponents(repl).spec(); |
+ |
+ // Remove the dangling '?' because it's ugly. |
+ base::ReplaceChars(result, "?", "", &result); |
+ return GURL(result); |
+} |
+ |
+std::pair<GURL, std::string> GetBaseURLAndQuery(const GURL& url) { |
+ if (!url.has_query()) |
+ return std::make_pair(url, ""); |
+ |
+ return std::make_pair(StripQueryFromURL(url), "?" + url.query()); |
+} |
+ |
+} // namespace mojo |