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, |