Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1806 Delegate processing of URL domains to crawler commons - add unit tests for host names with trailing dot ("www.apache.org.")

Sebastian Nagelbc2ae7e0c8d5
diff --git a/src/test/org/apache/nutch/util/TestURLUtil.java b/src/test/org/apache/nutch/util/TestURLUtil.java
index ad636048a..e074b6329 100644
--- a/src/test/org/apache/nutch/util/TestURLUtil.java
+++ b/src/test/org/apache/nutch/util/TestURLUtil.java
@@ -32,6 +32,10 @@ public class TestURLUtil {
url = new URL("http://lucene.apache.org/nutch");
Assert.assertEquals("apache.org", URLUtil.getDomainName(url));
+ // hostname with trailing dot
+ url = new URL("https://lucene.apache.org./nutch");
+ Assert.assertEquals("apache.org", URLUtil.getDomainName(url));
+
url = new URL("http://en.wikipedia.org/wiki/Java_coffee");
Assert.assertEquals("wikipedia.org", URLUtil.getDomainName(url));
@@ -85,6 +89,10 @@ public class TestURLUtil {
url = new URL("http://lucene.apache.org/nutch");
Assert.assertEquals("org", URLUtil.getDomainSuffix(url).getDomain());
+ // hostname with trailing dot
+ url = new URL("https://lucene.apache.org./nutch");
+ Assert.assertEquals("org", URLUtil.getDomainName(url));
+
url = new URL("http://140.211.11.130/foundation/contributing.html");
Assert.assertNull(URLUtil.getDomainSuffix(url));