author | Michael Kaply <mozilla@kaply.com> |
Thu, 23 Feb 2017 11:24:59 -0600 | |
changeset 344625 | d5bc4f182ec309b2d9577b5d7a0414d9d4ed7c0b |
parent 344624 | 9fe977a59fa1656a0a03b8ea1ad6c873520ef1d2 |
child 344626 | 564e1f5f214523adc78b1f5ee5a94428c8696343 |
push id | 31414 |
push user | cbook@mozilla.com |
push date | Fri, 24 Feb 2017 10:47:41 +0000 |
treeherder | mozilla-central@be661bae6cb9 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | snorp |
bugs | 1031210 |
milestone | 54.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/StringUtils.java | file | annotate | diff | comparison | revisions |
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/StringUtils.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/StringUtils.java @@ -97,30 +97,29 @@ public class StringUtils { return stripScheme(url, UrlFlags.NONE); } public static String stripScheme(String url, int flags) { if (url == null) { return url; } - int start = 0; - int end = url.length(); + String newURL = url; - if (url.startsWith("http://")) { - start = 7; - } else if (url.startsWith("https://") && flags == UrlFlags.STRIP_HTTPS) { - start = 8; + if (newURL.startsWith("http://")) { + newURL = newURL.replace("http://", ""); + } else if (newURL.startsWith("https://") && flags == UrlFlags.STRIP_HTTPS) { + newURL = newURL.replace("https://", ""); } - if (url.endsWith("/")) { - end--; + if (newURL.endsWith("/")) { + newURL = newURL.substring(0, newURL.length()-1); } - return url.substring(start, end); + return newURL; } public static boolean isHttpOrHttps(String url) { if (TextUtils.isEmpty(url)) { return false; } return url.startsWith("http://") || url.startsWith("https://");