private String computeNewImageLocation ( final String cssUri , final String imageUrl ) { LOG . debug ( "cssUri: {}, imageUrl {}" , cssUri , imageUrl ) ; final String cleanImageUrl = cleanImageUrl ( imageUrl ) ; // TODO move to ServletContextUriLocator as a helper method? // for the following input: /a/b/c/1.css => /a/b/c/ int idxLastSeparator = cssUri . lastIndexOf ( ServletContextUriLocator . PREFIX ) ; if ( idxLastSeparator == - 1 ) { if ( ClasspathUriLocator . isValid ( cssUri ) ) { idxLastSeparator = cssUri . lastIndexOf ( ClasspathUriLocator . PREFIX ) ; // find the index of ':' character used by classpath prefix if ( idxLastSeparator >= 0 ) { idxLastSeparator += ClasspathUriLocator . PREFIX . length ( ) - 1 ; } } if ( idxLastSeparator < 0 ) { throw new IllegalStateException ( "Invalid cssUri: " + cssUri + ". Should contain at least one '/' character!" ) ; } } final String cssUriFolder = cssUri . substring ( 0 , idxLastSeparator + 1 ) ; // remove '/' from imageUrl if it starts with one. final String processedImageUrl = cleanImageUrl . startsWith ( ServletContextUriLocator . PREFIX ) ? cleanImageUrl . substring ( 1 ) : cleanImageUrl ; final String computedImageLocation = cleanPath ( cssUriFolder + processedImageUrl ) ; LOG . debug ( "computedImageLocation: {}" , computedImageLocation ) ; return computedImageLocation ; }
Concatenates cssUri and imageUrl after few changes are applied to both input parameters .