Index: ios/web/navigation/navigation_item_impl.mm |
diff --git a/ios/web/navigation/navigation_item_impl.mm b/ios/web/navigation/navigation_item_impl.mm |
index 0b8aff9c295645f8c31b392fdb5cccc9f4d56d25..89273479169964979b58d49259a9403d35ba2e44 100644 |
--- a/ios/web/navigation/navigation_item_impl.mm |
+++ b/ios/web/navigation/navigation_item_impl.mm |
@@ -297,7 +297,7 @@ base::string16 NavigationItemImpl::GetDisplayTitleForURL(const GURL& url) { |
// For file:// URLs use the filename as the title, not the full path. |
if (url.SchemeIsFile()) { |
base::string16::size_type slashpos = title.rfind('/'); |
- if (slashpos != base::string16::npos) |
+ if (slashpos != base::string16::npos && slashpos != (title.size() - 1)) |
title = title.substr(slashpos + 1); |
} |