Bug 858340 - Domain autocompletion for Fennec. r=jchen

This commit is contained in:
Wes Johnston
2013-04-17 09:13:49 -07:00
parent 7a0b6c8f1c
commit 47b961cb8d
4 changed files with 172 additions and 34 deletions

View File

@@ -44,4 +44,26 @@ public class StringUtils {
// Otherwise, text is ambiguous, and we keep its status unchanged
return wasSearchQuery;
}
public static String stripScheme(String url) {
if (url == null)
return url;
if (url.startsWith("http://")) {
return url.substring(7);
}
return url;
}
public static String stripCommonSubdomains(String host) {
if (host == null)
return host;
// In contrast to desktop, we also strip mobile subdomains,
// since its unlikely users are intentionally typing them
if (host.startsWith("www.")) return host.substring(4);
else if (host.startsWith("mobile.")) return host.substring(7);
else if (host.startsWith("m.")) return host.substring(2);
return host;
}
}