@Test public void testStripCommonSubdomains() { assertEquals("mozilla.org", UrlUtils.stripCommonSubdomains("mozilla.org")); assertEquals("mozilla.org", UrlUtils.stripCommonSubdomains("www.mozilla.org")); assertEquals("mozilla.org", UrlUtils.stripCommonSubdomains("m.mozilla.org")); assertEquals("mozilla.org", UrlUtils.stripCommonSubdomains("mobile.mozilla.org")); assertEquals("random.mozilla.org", UrlUtils.stripCommonSubdomains("random.mozilla.org")); }
public static String stripCommonSubdomains(@Nullable String host) { if (host == null) { return null; } int start = 0; if (host.startsWith("www.")) { start = 4; } else if (host.startsWith("mobile.")) { start = 7; } else if (host.startsWith("m.")) { start = 2; } return host.substring(start); }
UrlUtils { public static String stripCommonSubdomains(@Nullable String host) { if (host == null) { return null; } int start = 0; if (host.startsWith("www.")) { start = 4; } else if (host.startsWith("mobile.")) { start = 7; } else if (host.startsWith("m.")) { start = 2; } return host.substring(start); } }
UrlUtils { public static String stripCommonSubdomains(@Nullable String host) { if (host == null) { return null; } int start = 0; if (host.startsWith("www.")) { start = 4; } else if (host.startsWith("mobile.")) { start = 7; } else if (host.startsWith("m.")) { start = 2; } return host.substring(start); }  }
UrlUtils { public static String stripCommonSubdomains(@Nullable String host) { if (host == null) { return null; } int start = 0; if (host.startsWith("www.")) { start = 4; } else if (host.startsWith("mobile.")) { start = 7; } else if (host.startsWith("m.")) { start = 2; } return host.substring(start); }  static String normalize(@NonNull String input); static boolean isUrl(String url); static boolean isValidSearchQueryUrl(String url); static boolean isHttpOrHttps(String url); static String createSearchUrl(Context context, String searchTerm); static String stripUserInfo(@Nullable String url); static boolean isPermittedResourceProtocol(@Nullable final String scheme); static boolean isSupportedProtocol(@Nullable final String scheme); static boolean isInternalErrorURL(final String url); static boolean urlsMatchExceptForTrailingSlash(final String url1, final String url2); static String stripCommonSubdomains(@Nullable String host); static String stripScheme(@Nullable String url); static String stripSchemeAndSubDomain(String url); static boolean isLocalizedContent(@Nullable String url); }
UrlUtils { public static String stripCommonSubdomains(@Nullable String host) { if (host == null) { return null; } int start = 0; if (host.startsWith("www.")) { start = 4; } else if (host.startsWith("mobile.")) { start = 7; } else if (host.startsWith("m.")) { start = 2; } return host.substring(start); }  static String normalize(@NonNull String input); static boolean isUrl(String url); static boolean isValidSearchQueryUrl(String url); static boolean isHttpOrHttps(String url); static String createSearchUrl(Context context, String searchTerm); static String stripUserInfo(@Nullable String url); static boolean isPermittedResourceProtocol(@Nullable final String scheme); static boolean isSupportedProtocol(@Nullable final String scheme); static boolean isInternalErrorURL(final String url); static boolean urlsMatchExceptForTrailingSlash(final String url1, final String url2); static String stripCommonSubdomains(@Nullable String host); static String stripScheme(@Nullable String url); static String stripSchemeAndSubDomain(String url); static boolean isLocalizedContent(@Nullable String url);  }