@Test public void testStripPublicSuffix() { Assert.assertEquals("", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "")); Assert.assertEquals("www.mozilla", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "www.mozilla.org")); Assert.assertEquals("www.google", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "www.google.com")); Assert.assertEquals("foobar", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "foobar.blogspot.com")); Assert.assertEquals("independent", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "independent.co.uk")); Assert.assertEquals("biz", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "biz.com.ua")); Assert.assertEquals("example", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "example.org")); Assert.assertEquals("example", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "example.pvt.k12.ma.us")); Assert.assertEquals("localhost", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "localhost")); Assert.assertEquals("firefox.mozilla", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "firefox.mozilla")); Assert.assertEquals("ουτοπία.δπθ", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "ουτοπία.δπθ.gr")); Assert.assertEquals("a网络A", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "a网络A.网络.Cn")); Assert.assertEquals("192.168.0.1", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "192.168.0.1")); Assert.assertEquals("asdflkj9uahsd", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "asdflkj9uahsd")); Assert.assertEquals("www.mozilla。home．example", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "www.mozilla。home．example｡org")); Assert.assertEquals("example", PublicSuffix.stripPublicSuffix(RuntimeEnvironment.application, "example.org")); }
@NonNull @WorkerThread public static String stripPublicSuffix(Context context, @NonNull String domain) { if (domain.length() == 0) { return domain; } final int index = findPublicSuffixIndex(context, domain); if (index == -1) { return domain; } return domain.substring(0, index); }
PublicSuffix { @NonNull @WorkerThread public static String stripPublicSuffix(Context context, @NonNull String domain) { if (domain.length() == 0) { return domain; } final int index = findPublicSuffixIndex(context, domain); if (index == -1) { return domain; } return domain.substring(0, index); } }
PublicSuffix { @NonNull @WorkerThread public static String stripPublicSuffix(Context context, @NonNull String domain) { if (domain.length() == 0) { return domain; } final int index = findPublicSuffixIndex(context, domain); if (index == -1) { return domain; } return domain.substring(0, index); }  }
PublicSuffix { @NonNull @WorkerThread public static String stripPublicSuffix(Context context, @NonNull String domain) { if (domain.length() == 0) { return domain; } final int index = findPublicSuffixIndex(context, domain); if (index == -1) { return domain; } return domain.substring(0, index); }  static void init(Context context); @NonNull @WorkerThread // This method might need to load data from disk static String stripPublicSuffix(Context context, @NonNull String domain); @NonNull @WorkerThread // This method might need to load data from disk static String getPublicSuffix(@NonNull final Context context, @NonNull final String domain, final int additionalPartCount); }
PublicSuffix { @NonNull @WorkerThread public static String stripPublicSuffix(Context context, @NonNull String domain) { if (domain.length() == 0) { return domain; } final int index = findPublicSuffixIndex(context, domain); if (index == -1) { return domain; } return domain.substring(0, index); }  static void init(Context context); @NonNull @WorkerThread // This method might need to load data from disk static String stripPublicSuffix(Context context, @NonNull String domain); @NonNull @WorkerThread // This method might need to load data from disk static String getPublicSuffix(@NonNull final Context context, @NonNull final String domain, final int additionalPartCount);  }