Index: jspwiki-war/src/test/java/org/apache/wiki/util/PropertyReaderTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- jspwiki-war/src/test/java/org/apache/wiki/util/PropertyReaderTest.java (date 1394486030000) +++ jspwiki-war/src/test/java/org/apache/wiki/util/PropertyReaderTest.java (revision ) @@ -9,6 +9,7 @@ public void testLocateClassPathResource() throws Exception { assertEquals("/ini/jspwiki.properties", PropertyReader.createResourceLocation("ini", "jspwiki.properties")); + assertEquals("/ini/jspwiki.properties", PropertyReader.createResourceLocation(null, "ini/jspwiki.properties")); assertEquals("/ini/jspwiki.properties", PropertyReader.createResourceLocation(null, "/ini/jspwiki.properties")); assertEquals("/jspwiki-custom.properties", PropertyReader.createResourceLocation(null, "/jspwiki-custom.properties")); assertEquals("/jspwiki.custom.cascade.1.ini", PropertyReader.createResourceLocation(null, "jspwiki.custom.cascade.1.ini")); Index: jspwiki-war/src/main/java/org/apache/wiki/util/PropertyReader.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- jspwiki-war/src/main/java/org/apache/wiki/util/PropertyReader.java (date 1394486030000) +++ jspwiki-war/src/main/java/org/apache/wiki/util/PropertyReader.java (revision ) @@ -376,33 +376,28 @@ StringBuilder result = new StringBuilder(); + // strip an ending "/" + String sanitizedPath = ( path != null && !path.isEmpty() && path.endsWith("/") ? path.substring(0, path.length()-1) : path); + + // strip leading "/" + String sanitizedName = ( name.startsWith("/") ? name.substring(1, name.length()) : name ); + // append the optional path - if( path == null || path.isEmpty() ) { + if( sanitizedPath == null || sanitizedPath.isEmpty() ) { result.append("/"); } else { - - if(!path.startsWith("/")) { + if( !sanitizedPath.startsWith("/" )) { result.append("/"); } - result.append(path); - - } - - // add a "/" between path and name if needed - - if( path != null ) { - if( !path.endsWith("/") || !name.startsWith("/")) + result.append(sanitizedPath); result.append("/"); } // append the name + result.append(sanitizedName); - result.append(name); - - // remove any double "/" - - return result.toString().replaceAll("//", "/"); + return result.toString(); } }