BasicTimelineFilter implements TimelineFilter { static String normalizeUrl(String url) { try { final HttpUrl parsedUrl = HttpUrl.parse(url); if (parsedUrl == null || parsedUrl.host() == null) { return IDN.toASCII(url).toLowerCase(Locale.US); } return parsedUrl.host().toLowerCase(Locale.US); } catch (IllegalArgumentException e) { return url; } } BasicTimelineFilter(FilterValues filterValues);  BasicTimelineFilter(FilterValues filterValues, Locale locale); @Override List<Tweet> filter(List<Tweet> tweets); @Override int totalFilters();  }
@Test public void testNormalizeUrl() { String url = "twitter.com"; String normalizedUrl = BasicTimelineFilter.normalizeUrl(url); assertEquals("twitter.com", normalizedUrl); url = "dev.twitter.com"; normalizedUrl = BasicTimelineFilter.normalizeUrl(url); assertEquals("dev.twitter.com", normalizedUrl); url = "http: normalizedUrl = BasicTimelineFilter.normalizeUrl(url); assertEquals("twitter.com", normalizedUrl); url = "http: normalizedUrl = BasicTimelineFilter.normalizeUrl(url); assertEquals("twitter.com", normalizedUrl); url = "https: normalizedUrl = BasicTimelineFilter.normalizeUrl(url); assertEquals("twitter.com", normalizedUrl); url = "транспорт.com"; normalizedUrl = BasicTimelineFilter.normalizeUrl(url); assertEquals("xn--80a0addceeeh.com", normalizedUrl); url = "https: normalizedUrl = BasicTimelineFilter.normalizeUrl(url); assertEquals("xn--80a0addceeeh.com", normalizedUrl); }
@Test public void testNormalizeUrl_withProhibitedCodePoint() { final String url = "twitter\u180E.com"; final String normalizedUrl = BasicTimelineFilter.normalizeUrl(url); assertEquals(url, normalizedUrl); }