mirror of https://github.com/apache/maven.git
[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:
parent
33ae0b2003
commit
e45d82e196
|
@ -37,8 +37,6 @@ public class DefaultUrlNormalizer
|
||||||
|
|
||||||
if ( result != null )
|
if ( result != null )
|
||||||
{
|
{
|
||||||
result = result.replaceAll( "(?<![:/])/+", "/" );
|
|
||||||
|
|
||||||
while ( true )
|
while ( true )
|
||||||
{
|
{
|
||||||
int idx = result.indexOf( "/../" );
|
int idx = result.indexOf( "/../" );
|
||||||
|
@ -46,7 +44,12 @@ public class DefaultUrlNormalizer
|
||||||
{
|
{
|
||||||
break;
|
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 )
|
if ( parent < 0 )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -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/parent/../child" ) );
|
||||||
assertEquals( "http://server.org/child", normalize( "http://server.org/grand/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( "scm:hg:ssh://localhost//home/user", normalize( "scm:hg:ssh://localhost//home/user" ) );
|
||||||
assertEquals( "http://server.org/parent/child", normalize( "http://server.org/parent//child" ) );
|
|
||||||
|
|
||||||
assertEquals( "file:////UNC/server", normalize( "file:////UNC/server" ) );
|
assertEquals( "file:////UNC/server", normalize( "file:////UNC/server" ) );
|
||||||
assertEquals( "[fetch=]http://server.org/[push=]ssh://server.org/",
|
assertEquals( "[fetch=]http://server.org/[push=]ssh://server.org/",
|
||||||
normalize( "[fetch=]http://server.org/[push=]ssh://server.org/" ) );
|
normalize( "[fetch=]http://server.org/[push=]ssh://server.org/" ) );
|
||||||
|
|
Loading…
Reference in New Issue