@ -65,7 +65,8 @@ public abstract class ResourceHandlerUtils {
@@ -65,7 +65,8 @@ public abstract class ResourceHandlerUtils {
else {
path = location . getURL ( ) . getPath ( ) ;
}
assertLocationPath ( path ) ;
Assert . isTrue ( path . endsWith ( FOLDER_SEPARATOR ) | | path . endsWith ( WINDOWS_FOLDER_SEPARATOR ) ,
"Resource location does not end with slash: " + path ) ;
}
catch ( IOException ex ) {
// ignore
@ -73,12 +74,18 @@ public abstract class ResourceHandlerUtils {
@@ -73,12 +74,18 @@ public abstract class ResourceHandlerUtils {
}
/ * *
* Assert the given location path is a directory and ends on slash .
* Check if the given static resource location path ends with a trailing
* slash , and append it if necessary .
* @param path the location path
* @return the resulting path to use
* /
public static void assertLocationPath ( @Nullable String path ) {
Assert . notNull ( path , "Resource location path must not be null" ) ;
Assert . isTrue ( path . endsWith ( FOLDER_SEPARATOR ) | | path . endsWith ( WINDOWS_FOLDER_SEPARATOR ) ,
"Resource location does not end with slash: " + path ) ;
public static String initLocationPath ( String path ) {
String separator = ( path . contains ( FOLDER_SEPARATOR ) ? FOLDER_SEPARATOR : WINDOWS_FOLDER_SEPARATOR ) ;
if ( ! path . endsWith ( separator ) ) {
path = path . concat ( separator ) ;
logger . warn ( "Appended trailing slash to static resource location: " + path ) ;
}
return path ;
}
/ * *