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

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: minor improvements 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
« no previous file with comments | « components/omnibox/autocomplete_match.h ('k') | components/omnibox/autocomplete_match_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/omnibox/autocomplete_match.cc
diff --git a/components/omnibox/autocomplete_match.cc b/components/omnibox/autocomplete_match.cc
index d19f8e9b56031961555e2f2db05fc075080bfaa3..3606e2c5f24470e627fd8ed0185690b61e15389b 100644
--- a/components/omnibox/autocomplete_match.cc
+++ b/components/omnibox/autocomplete_match.cc
@@ -415,6 +415,21 @@ GURL AutocompleteMatch::GURLToStrippedGURL(
needs_replacement = true;
}
+ // Remove any trailing slash (if it's not a lone slash), or add a slash (to
+ // make a lone slash) if the path is empty. (We can't unconditionally
+ // remove even lone slashes because for some schemes the path must consist
+ // of at least a slash.)
+ const std::string& path = stripped_destination_url.path();
+ 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()) {
+ static const char slash[] = "/";
+ 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,
« no previous file with comments | « components/omnibox/autocomplete_match.h ('k') | components/omnibox/autocomplete_match_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698