public ArtifactReference toArtifactReference( String requestedPath )
throws LayoutException
{
- if ( isDefault( requestedPath ) )
+ if ( StringUtils.isBlank( requestedPath ) )
+ {
+ throw new LayoutException( "Blank request path is not a valid." );
+ }
+
+ String path = requestedPath;
+ while ( path.startsWith( "/" ) )
+ {
+ path = path.substring( 1 );
+
+ // Only slash? that's bad, mmm-kay?
+ if ( "/".equals( path ) )
+ {
+ throw new LayoutException( "Invalid request path: Slash only." );
+ }
+ }
+
+ if ( isDefault( path ) )
{
- return DefaultPathParser.toArtifactReference( requestedPath );
+ return DefaultPathParser.toArtifactReference( path );
}
- else if ( isLegacy( requestedPath ) )
+ else if ( isLegacy( path ) )
{
- return LegacyPathParser.toArtifactReference( requestedPath );
+ return LegacyPathParser.toArtifactReference( path );
}
else
{
throws Exception
{
assertValid( "org.apache.derby/poms/derby-10.2.2.0.pom", "org.apache.derby", "derby", "10.2.2.0", null, "pom" );
+ // Starting slash should not prevent detection.
+ assertValid( "/org.apache.derby/poms/derby-10.2.2.0.pom", "org.apache.derby", "derby", "10.2.2.0", null, "pom" );
}
-
+
public void testValidDefaultDerbyPom()
throws Exception
{