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

Unified Diff: components/omnibox/autocomplete_match.cc

Issue 1169173005: Omnibox - Mark As Duplicates URLs that only differ by a trailing slash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: peter's optimizations Created 5 years, 6 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: components/omnibox/autocomplete_match.cc
diff --git a/components/omnibox/autocomplete_match.cc b/components/omnibox/autocomplete_match.cc
index d19f8e9b56031961555e2f2db05fc075080bfaa3..63d499fcfd84cd2cf684dc034aaeb974f92548e2 100644
--- a/components/omnibox/autocomplete_match.cc
+++ b/components/omnibox/autocomplete_match.cc
@@ -415,6 +415,21 @@ GURL AutocompleteMatch::GURLToStrippedGURL(
needs_replacement = true;
}
+ // Remove the trailing slash if any (if it's not a lone slash), and
Peter Kasting 2015/06/12 19:30:36 Nit: "Remove any trailing slash ..."; and -> or
Mark P 2015/06/12 19:57:57 Done. (removed "if any", replaced "the" with "any
+ // add a slash (to make a lone slash) if the path is empty.
Peter Kasting 2015/06/12 19:30:36 Nit: Maybe add: "(We can't unconditionally remove
Mark P 2015/06/12 19:57:57 Okay. Done.
+ const std::string& path = stripped_destination_url.path();
+ // |slash| lives at this scope rather than inside the if
+ // statement because it has to live until the ReplaceComponents() call below.
+ std::string slash("/");
Peter Kasting 2015/06/12 19:30:36 Can we do: static const char slash[] = "/"; ?
Mark P 2015/06/12 19:57:57 Apparently we can. Done.
+ if ((path.length() > 1) && (path[path.length() - 1] == '/')) {
+ replacements.SetPathStr(
+ base::StringPiece(path).substr(0, path.length() - 1));
+ needs_replacement = true;
+ } else if (path.empty()) {
+ replacements.SetPathStr(base::StringPiece(slash));
+ needs_replacement = true;
+ }
+
// Replace https protocol with http protocol.
if (stripped_destination_url.SchemeIs(url::kHttpsScheme)) {
replacements.SetScheme(url::kHttpScheme,

Powered by Google App Engine
This is Rietveld 408576698