summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/url_fixer_upper.cc15
-rw-r--r--chrome/browser/url_fixer_upper_unittest.cc6
2 files changed, 11 insertions, 10 deletions
diff --git a/chrome/browser/url_fixer_upper.cc b/chrome/browser/url_fixer_upper.cc
index a62694d..8ad4fbb 100644
--- a/chrome/browser/url_fixer_upper.cc
+++ b/chrome/browser/url_fixer_upper.cc
@@ -287,16 +287,11 @@ wstring URLFixerUpper::SegmentURL(const wstring& text,
parts->scheme.reset();
}
- // Check to see if we've found a scheme we liked.
- int scheme_end;
- if (parts->scheme.is_valid()) {
- // Remember the end of the scheme.
- scheme_end = parts->scheme.end();
- } else {
- // Having been unable to extract a scheme, we default to HTTP.
- scheme.assign(L"http");
- scheme_end = 0;
- }
+ // When we couldn't find a scheme in the input, we need to pick one. Normally
+ // we choose http, but if the URL starts with "ftp.", we match other browsers
+ // and choose ftp.
+ if (!parts->scheme.is_valid())
+ scheme.assign(StartsWith(text, L"ftp.", false) ? L"ftp" : L"http");
// Cannonicalize the scheme.
StringToLowerASCII(&scheme);
diff --git a/chrome/browser/url_fixer_upper_unittest.cc b/chrome/browser/url_fixer_upper_unittest.cc
index e793505..111874b 100644
--- a/chrome/browser/url_fixer_upper_unittest.cc
+++ b/chrome/browser/url_fixer_upper_unittest.cc
@@ -173,6 +173,12 @@ struct fixup_case {
// a clean way to guess this isn't the new-and-exciting "user" scheme.
{L"user:passwd@www.google.com:8080/", L"", L"user:passwd@www.google.com:8080/"},
//{L"file:///c:/foo/bar%20baz.txt", L"", L"file:///C:/foo/bar%20baz.txt"},
+ {L"ftp.google.com", L"", L"ftp://ftp.google.com/"},
+ {L" ftp.google.com", L"", L"ftp://ftp.google.com/"},
+ {L"FTP.GooGle.com", L"", L"ftp://FTP.GooGle.com/"},
+ {L"ftpblah.google.com", L"", L"http://ftpblah.google.com/"},
+ {L"ftp", L"", L"http://ftp/"},
+ {L"google.ftp.com", L"", L"http://google.ftp.com/"},
};
TEST(URLFixerUpperTest, FixupURL) {