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

Unified Diff: shell/application_manager/query_util.cc

Issue 972473003: Strip query string before applying url mapping. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698