/** * A transformer can use this method when a resource being transformed * contains links to other resources. Such links need to be replaced with the * public facing link as determined by the resource resolver chain (e.g. the * public URL may have a version inserted). * @param resourcePath the path to a resource that needs to be re-written * @param request the current request * @param resource the resource being transformed * @param transformerChain the transformer chain * @return the resolved URL, or {@code} if not resolvable */ @Nullable protected String resolveUrlPath(String resourcePath, HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) { if (resourcePath.startsWith("/")) { // full resource path ResourceUrlProvider urlProvider = findResourceUrlProvider(request); return (urlProvider != null ? urlProvider.getForRequestUrl(request, resourcePath) : null); } else { // try resolving as relative path return transformerChain.getResolverChain().resolveUrlPath( resourcePath, Collections.singletonList(resource)); } }
/** * A transformer can use this method when a resource being transformed * contains links to other resources. Such links need to be replaced with the * public facing link as determined by the resource resolver chain (e.g. the * public URL may have a version inserted). * @param resourcePath the path to a resource that needs to be re-written * @param request the current request * @param resource the resource being transformed * @param transformerChain the transformer chain * @return the resolved URL, or {@code} if not resolvable */ @Nullable protected String resolveUrlPath(String resourcePath, HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) { if (resourcePath.startsWith("/")) { // full resource path ResourceUrlProvider urlProvider = findResourceUrlProvider(request); return (urlProvider != null ? urlProvider.getForRequestUrl(request, resourcePath) : null); } else { // try resolving as relative path return transformerChain.getResolverChain().resolveUrlPath( resourcePath, Collections.singletonList(resource)); } }
private LineOutput processLine(LineInfo info, HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) { if (!info.isLink()) { return new LineOutput(info.getLine(), null); } Resource appCacheResource = transformerChain.getResolverChain() .resolveResource(null, info.getLine(), Collections.singletonList(resource)); String path = info.getLine(); String absolutePath = toAbsolutePath(path, request); String newPath = resolveUrlPath(absolutePath, request, resource, transformerChain); return new LineOutput((newPath != null ? newPath : path), appCacheResource); }
private LineOutput processLine(LineInfo info, HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) { if (!info.isLink()) { return new LineOutput(info.getLine(), null); } Resource appCacheResource = transformerChain.getResolverChain() .resolveResource(null, info.getLine(), Collections.singletonList(resource)); String path = info.getLine(); String absolutePath = toAbsolutePath(path, request); String newPath = resolveUrlPath(absolutePath, request, resource, transformerChain); return new LineOutput((newPath != null ? newPath : path), appCacheResource); }
/** * A transformer can use this method when a resource being transformed * contains links to other resources. Such links need to be replaced with the * public facing link as determined by the resource resolver chain (e.g. the * public URL may have a version inserted). * @param resourcePath the path to a resource that needs to be re-written * @param request the current request * @param resource the resource being transformed * @param transformerChain the transformer chain * @return the resolved URL, or {@code} if not resolvable */ protected String resolveUrlPath(String resourcePath, HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) { if (resourcePath.startsWith("/")) { // full resource path ResourceUrlProvider urlProvider = findResourceUrlProvider(request); return (urlProvider != null ? urlProvider.getForRequestUrl(request, resourcePath) : null); } else { // try resolving as relative path return transformerChain.getResolverChain().resolveUrlPath( resourcePath, Collections.singletonList(resource)); } }