Apache Nutch is an extensible and scalable web crawler
NUTCH-1011 Remove duplicate slashes from URLs
Markus Jelsma60f0dbff4e5e
diff --git a/CHANGES.txt b/CHANGES.txtindex 1797f53c0..8aa148995 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -2,6 +2,8 @@ Nutch Change LogRelease 1.4 - Current development+* NUTCH-1011 Normalize duplicate slashes in URL's (markus)+* NUTCH-993 NullPointerException at FetcherOutputFormat.checkOutputSpecs (Christian Guegi via jnioche)* NUTCH-1013 Migrate RegexURLNormalizer from Apache ORO to java.util.regex (markus)diff --git a/conf/regex-normalize.xml.template b/conf/regex-normalize.xml.templateindex 5b82f6baa..95f755767 100644--- a/conf/regex-normalize.xml.template+++ b/conf/regex-normalize.xml.template@@ -63,4 +63,10 @@<substitution></substitution></regex>+<!-- removes duplicate slashes -->+<regex>+ <pattern>(?<!:)/{2,}</pattern>+ <substitution>/</substitution>+</regex>+</regex-normalize>diff --git a/src/test/org/apache/nutch/net/TestURLNormalizers.java b/src/test/org/apache/nutch/net/TestURLNormalizers.javaindex 7d2d58533..2d95b02aa 100644--- a/src/test/org/apache/nutch/net/TestURLNormalizers.java+++ b/src/test/org/apache/nutch/net/TestURLNormalizers.java@@ -39,6 +39,15 @@ public class TestURLNormalizers extends TestCase {} catch (MalformedURLException mue) {fail(mue.toString());}++ // NUTCH-1011 - Get rid of superfluous slashes+ try {+ String normalizedSlashes = normalizers.normalize("http://www.example.org//path/to//somewhere.html", URLNormalizers.SCOPE_DEFAULT);+ assertEquals(normalizedSlashes, "http://www.example.org/path/to/somewhere.html");+ } catch (MalformedURLException mue) {+ fail(mue.toString());+ }+// check the orderint pos1 = -1, pos2 = -1;URLNormalizer[] impls = normalizers.getURLNormalizers(URLNormalizers.SCOPE_DEFAULT);