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

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: finally works 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..242caf71fd5570fd1075254aa3a5b9b98a1d99fa 100644
--- a/components/omnibox/autocomplete_match.cc
+++ b/components/omnibox/autocomplete_match.cc
@@ -415,6 +415,16 @@ GURL AutocompleteMatch::GURLToStrippedGURL(
needs_replacement = true;
}
+ // Add a trailing slash if the path does not have one.
Peter Kasting 2015/06/11 23:05:37 Nit: I might add "It's OK if this adds a slash eve
Mark P 2015/06/12 17:25:57 Done. (I thought it was clear from preexisting co
Peter Kasting 2015/06/12 17:49:04 It's clear we're not going to navigate there -- bu
Mark P 2015/06/12 18:04:59 I think the problem with lone slashes cannot be ea
Peter Kasting 2015/06/12 18:25:37 Well, just because another protocol may allow an e
+ const std::string& path = stripped_destination_url.path();
+ // |path_with_extra_slash| lives at this scope rather than inside the if
+ // statement because it has to live until the ReplaceComponents() call below.
+ std::string path_with_extra_slash(path + '/');
+ if (path.empty() || (path.back() != '/')) {
+ replacements.SetPathStr(base::StringPiece(path_with_extra_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