@Test public void urlsMatchExceptForTrailingSlash() { assertTrue(UrlUtils.urlsMatchExceptForTrailingSlash("http: assertTrue(UrlUtils.urlsMatchExceptForTrailingSlash("http: assertTrue(UrlUtils.urlsMatchExceptForTrailingSlash("http: assertFalse(UrlUtils.urlsMatchExceptForTrailingSlash("http: assertFalse(UrlUtils.urlsMatchExceptForTrailingSlash("http: assertFalse(UrlUtils.urlsMatchExceptForTrailingSlash("http: assertFalse(UrlUtils.urlsMatchExceptForTrailingSlash("https: assertFalse(UrlUtils.urlsMatchExceptForTrailingSlash("http: assertFalse(UrlUtils.urlsMatchExceptForTrailingSlash("http: assertFalse(UrlUtils.urlsMatchExceptForTrailingSlash("http: assertTrue(UrlUtils.urlsMatchExceptForTrailingSlash("http: assertTrue(UrlUtils.urlsMatchExceptForTrailingSlash("http: assertTrue(UrlUtils.urlsMatchExceptForTrailingSlash("http: }
public static boolean urlsMatchExceptForTrailingSlash(final String url1, final String url2) { if (url1 == null || url2 == null) { return false; } int lengthDifference = url1.length() - url2.length(); if (lengthDifference == 0) { return url1.equalsIgnoreCase(url2); } else if (lengthDifference == 1) { return url1.charAt(url1.length() - 1) == '/' && url1.regionMatches(true, 0, url2, 0, url2.length()); } else if (lengthDifference == -1) { return url2.charAt(url2.length() - 1) == '/' && url2.regionMatches(true, 0, url1, 0, url1.length()); } return false; }
UrlUtils { public static boolean urlsMatchExceptForTrailingSlash(final String url1, final String url2) { if (url1 == null || url2 == null) { return false; } int lengthDifference = url1.length() - url2.length(); if (lengthDifference == 0) { return url1.equalsIgnoreCase(url2); } else if (lengthDifference == 1) { return url1.charAt(url1.length() - 1) == '/' && url1.regionMatches(true, 0, url2, 0, url2.length()); } else if (lengthDifference == -1) { return url2.charAt(url2.length() - 1) == '/' && url2.regionMatches(true, 0, url1, 0, url1.length()); } return false; } }
UrlUtils { public static boolean urlsMatchExceptForTrailingSlash(final String url1, final String url2) { if (url1 == null || url2 == null) { return false; } int lengthDifference = url1.length() - url2.length(); if (lengthDifference == 0) { return url1.equalsIgnoreCase(url2); } else if (lengthDifference == 1) { return url1.charAt(url1.length() - 1) == '/' && url1.regionMatches(true, 0, url2, 0, url2.length()); } else if (lengthDifference == -1) { return url2.charAt(url2.length() - 1) == '/' && url2.regionMatches(true, 0, url1, 0, url1.length()); } return false; }  }
UrlUtils { public static boolean urlsMatchExceptForTrailingSlash(final String url1, final String url2) { if (url1 == null || url2 == null) { return false; } int lengthDifference = url1.length() - url2.length(); if (lengthDifference == 0) { return url1.equalsIgnoreCase(url2); } else if (lengthDifference == 1) { return url1.charAt(url1.length() - 1) == '/' && url1.regionMatches(true, 0, url2, 0, url2.length()); } else if (lengthDifference == -1) { return url2.charAt(url2.length() - 1) == '/' && url2.regionMatches(true, 0, url1, 0, url1.length()); } return false; }  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 boolean urlsMatchExceptForTrailingSlash(final String url1, final String url2) { if (url1 == null || url2 == null) { return false; } int lengthDifference = url1.length() - url2.length(); if (lengthDifference == 0) { return url1.equalsIgnoreCase(url2); } else if (lengthDifference == 1) { return url1.charAt(url1.length() - 1) == '/' && url1.regionMatches(true, 0, url2, 0, url2.length()); } else if (lengthDifference == -1) { return url2.charAt(url2.length() - 1) == '/' && url2.regionMatches(true, 0, url1, 0, url1.length()); } return false; }  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);  }