[MNG-4966] Preserve double slashes in the scm connection url - identifies absolute repository paths for mercurial

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1056720 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2011-01-08 14:46:27 +00:00
parent 33ae0b2003
commit e45d82e196
2 changed files with 11 additions and 7 deletions

View File

@ -37,8 +37,6 @@ public String normalize( String url )
if ( result != null )
{
result = result.replaceAll( "(?<![:/])/+", "/" );
while ( true )
{
int idx = result.indexOf( "/../" );
@ -46,7 +44,12 @@ public String normalize( String url )
{
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;

View File

@ -69,13 +69,14 @@ public void testRemovalOfParentRefs()
{
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/" ) );