maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r1056720 - in /maven/maven-3/trunk/maven-model-builder/src: main/java/org/apache/maven/model/path/DefaultUrlNormalizer.java test/java/org/apache/maven/model/path/DefaultUrlNormalizerTest.java
Date Sat, 08 Jan 2011 14:46:27 GMT
Author: bentmann
Date: Sat Jan  8 14:46:27 2011
New Revision: 1056720

URL: http://svn.apache.org/viewvc?rev=1056720&view=rev
Log:
[MNG-4966] Preserve double slashes in the scm connection url - identifies absolute repository
paths for mercurial

Modified:
    maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultUrlNormalizer.java
    maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/path/DefaultUrlNormalizerTest.java

Modified: maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultUrlNormalizer.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultUrlNormalizer.java?rev=1056720&r1=1056719&r2=1056720&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultUrlNormalizer.java
(original)
+++ maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/path/DefaultUrlNormalizer.java
Sat Jan  8 14:46:27 2011
@@ -37,8 +37,6 @@ public class DefaultUrlNormalizer
 
         if ( result != null )
         {
-            result = result.replaceAll( "(?<![:/])/+", "/" );
-
             while ( true )
             {
                 int idx = result.indexOf( "/../" );
@@ -46,7 +44,12 @@ public class DefaultUrlNormalizer
                 {
                     break;
                 }
-                int parent = result.lastIndexOf( '/', idx - 1 );
+                int parent = idx - 1;
+                while ( parent >= 0 && result.charAt( parent ) == '/' )
+                {
+                    parent--;
+                }
+                parent = result.lastIndexOf( '/', parent );
                 if ( parent < 0 )
                 {
                     break;

Modified: maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/path/DefaultUrlNormalizerTest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/path/DefaultUrlNormalizerTest.java?rev=1056720&r1=1056719&r2=1056720&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/path/DefaultUrlNormalizerTest.java
(original)
+++ maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/path/DefaultUrlNormalizerTest.java
Sat Jan  8 14:46:27 2011
@@ -69,13 +69,14 @@ public class DefaultUrlNormalizerTest
     {
         assertEquals( "http://server.org/child", normalize( "http://server.org/parent/../child"
) );
         assertEquals( "http://server.org/child", normalize( "http://server.org/grand/parent/../../child"
) );
+
+        assertEquals( "http://server.org//child", normalize( "http://server.org/parent/..//child"
) );
+        assertEquals( "http://server.org/child", normalize( "http://server.org/parent//../child"
) );
     }
 
-    public void testRemovalOfDoubleSlashes()
+    public void testPreservationOfDoubleSlashes()
     {
-        assertEquals( "http://server.org/dir/", normalize( "http://server.org/dir//" ) );
-        assertEquals( "http://server.org/parent/child", normalize( "http://server.org/parent//child"
) );
-
+        assertEquals( "scm:hg:ssh://localhost//home/user", normalize( "scm:hg:ssh://localhost//home/user"
) );
         assertEquals( "file:////UNC/server", normalize( "file:////UNC/server" ) );
         assertEquals( "[fetch=]http://server.org/[push=]ssh://server.org/",
                       normalize( "[fetch=]http://server.org/[push=]ssh://server.org/" ) );



Mime
View raw message