@ -1,5 +1,5 @@
/ *
/ *
* Copyright 2002 - 2016 the original author or authors .
* Copyright 2002 - 2017 the original author or authors .
*
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* you may not use this file except in compliance with the License .
@ -17,9 +17,9 @@
package org.springframework.web.servlet.resource ;
package org.springframework.web.servlet.resource ;
import java.util.List ;
import java.util.List ;
import javax.servlet.http.HttpServletRequest ;
import javax.servlet.http.HttpServletRequest ;
import org.webjars.MultipleMatchesException ;
import org.webjars.WebJarAssetLocator ;
import org.webjars.WebJarAssetLocator ;
import org.springframework.core.io.Resource ;
import org.springframework.core.io.Resource ;
@ -99,26 +99,16 @@ public class WebJarsResourceResolver extends AbstractResourceResolver {
}
}
protected String findWebJarResourcePath ( String path ) {
protected String findWebJarResourcePath ( String path ) {
try {
int startOffset = ( path . startsWith ( "/" ) ? 1 : 0 ) ;
int startOffset = ( path . startsWith ( "/" ) ? 1 : 0 ) ;
int endOffset = path . indexOf ( "/" , 1 ) ;
int endOffset = path . indexOf ( "/" , 1 ) ;
if ( endOffset ! = - 1 ) {
if ( endOffset ! = - 1 ) {
String webjar = path . substring ( startOffset , endOffset ) ;
String webjar = path . substring ( startOffset , endOffset ) ;
String partialPath = path . substring ( endOffset ) ;
String partialPath = path . substring ( endOffset + 1 ) ;
String webJarPath = webJarAssetLocator . getFullPath ( webjar , partialPath ) ;
String webJarPath = webJarAssetLocator . getFullPathExact ( webjar , partialPath ) ;
if ( webJarPath ! = null ) {
return webJarPath . substring ( WEBJARS_LOCATION_LENGTH ) ;
return webJarPath . substring ( WEBJARS_LOCATION_LENGTH ) ;
}
}
}
}
catch ( MultipleMatchesException ex ) {
if ( logger . isWarnEnabled ( ) ) {
logger . warn ( "WebJar version conflict for \"" + path + "\"" , ex ) ;
}
}
catch ( IllegalArgumentException ex ) {
if ( logger . isTraceEnabled ( ) ) {
logger . trace ( "No WebJar resource found for \"" + path + "\"" ) ;
}
}
return null ;
return null ;
}
}