public String rewrite(final String cssUri,final String imageUrl){
  notNull(cssUri);
  notNull(imageUrl);
  if (StringUtils.isEmpty(imageUrl)) {
    return imageUrl;
  }
  if (ServletContextUriLocator.isValid(cssUri)) {
    if (ServletContextUriLocator.isValid(imageUrl)) {
      return prependContextPath(imageUrl);
    }
    if (ServletContextUriLocator.isProtectedResource(cssUri)) {
      return context.proxyPrefix + computeNewImageLocation(cssUri,imageUrl);
    }
    final String aggregatedPathPrefix=computeAggregationPathPrefix(context.aggregatedFolderPath);
    LOG.debug("computed aggregatedPathPrefix {}",aggregatedPathPrefix);
    String newImageLocation=computeNewImageLocation(aggregatedPathPrefix + cssUri,imageUrl);
    if (newImageLocation.startsWith(ServletContextUriLocator.PREFIX)) {
      newImageLocation=prependContextPath(newImageLocation);
    }
    LOG.debug("newImageLocation: {}",newImageLocation);
    return newImageLocation;
  }
  if (ClasspathUriLocator.isValid(cssUri)) {
    final String proxyUrl=context.proxyPrefix + computeNewImageLocation(cssUri,imageUrl);
    final String contextRelativeUrl=prependContextPath(imageUrl);
    return (ServletContextUriLocator.isValid(imageUrl) ? contextRelativeUrl : proxyUrl);
  }
  if (UrlUriLocator.isValid(cssUri)) {
    final String computedCssUri=ServletContextUriLocator.isValid(imageUrl) ? computeCssUriForExternalServer(cssUri) : cssUri;
    return computeNewImageLocation(computedCssUri,imageUrl);
  }
  throw new WroRuntimeException("Could not replace imageUrl: " + imageUrl + ", contained at location: "+ cssUri);
}

public String rewrite ( final String cssUri , final String imageUrl ) { notNull ( cssUri ) ; notNull ( imageUrl ) ; if ( StringUtils . isEmpty ( imageUrl ) ) { return imageUrl ; } if ( ServletContextUriLocator . isValid ( cssUri ) ) { if ( ServletContextUriLocator . isValid ( imageUrl ) ) { return prependContextPath ( imageUrl ) ; } if ( ServletContextUriLocator . isProtectedResource ( cssUri ) ) { return context . proxyPrefix + computeNewImageLocation ( cssUri , imageUrl ) ; } final String aggregatedPathPrefix = computeAggregationPathPrefix ( context . aggregatedFolderPath ) ; LOG . debug ( "computed aggregatedPathPrefix {}" , aggregatedPathPrefix ) ; String newImageLocation = computeNewImageLocation ( aggregatedPathPrefix + cssUri , imageUrl ) ; if ( newImageLocation . startsWith ( ServletContextUriLocator . PREFIX ) ) { newImageLocation = prependContextPath ( newImageLocation ) ; } LOG . debug ( "newImageLocation: {}" , newImageLocation ) ; return newImageLocation ; } if ( ClasspathUriLocator . isValid ( cssUri ) ) { final String proxyUrl = context . proxyPrefix + computeNewImageLocation ( cssUri , imageUrl ) ; final String contextRelativeUrl = prependContextPath ( imageUrl ) ; return ( ServletContextUriLocator . isValid ( imageUrl ) ? contextRelativeUrl : proxyUrl ) ; } if ( UrlUriLocator . isValid ( cssUri ) ) { final String computedCssUri = ServletContextUriLocator . isValid ( imageUrl ) ? computeCssUriForExternalServer ( cssUri ) : cssUri ; return computeNewImageLocation ( computedCssUri , imageUrl ) ; } throw new WroRuntimeException ( "Could not replace imageUrl: " + imageUrl + ", contained at location: " + cssUri ) ; }
computes the url of the image to be replaced in a css resource .
