зеркало из https://github.com/mozilla/gecko-dev.git
Bug 884336 - Remove trailing "/" from URLs when pref to show URLs in titlebar is enabled. r=wesj
This commit is contained in:
Родитель
90744864f2
Коммит
32f486b3cf
|
@ -46,24 +46,41 @@ public class StringUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String stripScheme(String url) {
|
public static String stripScheme(String url) {
|
||||||
if (url == null)
|
if (url == null) {
|
||||||
return url;
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
int start = 0;
|
||||||
|
int end = url.length();
|
||||||
|
|
||||||
if (url.startsWith("http://")) {
|
if (url.startsWith("http://")) {
|
||||||
return url.substring(7);
|
start = 7;
|
||||||
}
|
}
|
||||||
return url;
|
|
||||||
|
if (url.endsWith("/")) {
|
||||||
|
end--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return url.substring(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String stripCommonSubdomains(String host) {
|
public static String stripCommonSubdomains(String host) {
|
||||||
if (host == null)
|
if (host == null) {
|
||||||
return host;
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
// In contrast to desktop, we also strip mobile subdomains,
|
// In contrast to desktop, we also strip mobile subdomains,
|
||||||
// since its unlikely users are intentionally typing them
|
// since its unlikely users are intentionally typing them
|
||||||
if (host.startsWith("www.")) return host.substring(4);
|
int start = 0;
|
||||||
else if (host.startsWith("mobile.")) return host.substring(7);
|
|
||||||
else if (host.startsWith("m.")) return host.substring(2);
|
|
||||||
return host;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (host.startsWith("www.")) {
|
||||||
|
start = 4;
|
||||||
|
} else if (host.startsWith("mobile.")) {
|
||||||
|
start = 7;
|
||||||
|
} else if (host.startsWith("m.")) {
|
||||||
|
start = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return host.substring(start);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче