Bug 913214 - Create StringUtils method to provide readable URL / title string, r=wesj, sriram

This commit is contained in:
Mark Capella
2013-09-17 23:54:48 -04:00
parent 6c7eed9c9e
commit d23b29b077
4 changed files with 19 additions and 10 deletions

View File

@@ -47,7 +47,16 @@ public class StringUtils {
return wasSearchQuery;
}
public static class UrlFlags {
public static final int NONE = 0;
public static final int STRIP_HTTPS = 1;
}
public static String stripScheme(String url) {
return stripScheme(url, UrlFlags.NONE);
}
public static String stripScheme(String url, int flags) {
if (url == null) {
return url;
}
@@ -57,6 +66,8 @@ public class StringUtils {
if (url.startsWith("http://")) {
start = 7;
} else if (url.startsWith("https://") && flags == UrlFlags.STRIP_HTTPS) {
start = 8;
}
if (url.endsWith("/")) {