Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CssLinkResourceTransformer does not use resolveUrlPath properly [SPR-12137] #16752

Closed
spring-projects-issues opened this issue Aug 30, 2014 · 2 comments
Assignees
Labels
in: web type: bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Aug 30, 2014

Guillaume DROUET opened SPR-12137 and commented

Hi,

When the CssLinkResourceTransformer use the ResourceResolverChain#resolveUrlPath method to retrieve a resource referenced with url or @import, it gives as parameter the complete path. This is not what the ResourceUrlProvider does: before calling the chain, it removes the beginning of the path corresponding to the matching pattern.

Imagine you have the following configuration: registry.addResourceHandler("/css/**").addResourceLocations("classpath:/statics/css/")

If I resolve '/css/app.css' with ResourceUrlProvider, PathResourceResolver receives 'app.css' to resolve.

Now imagine in app.css a statement like this: @import "/css/app2.css";
In that case PathResourceResolver receives '/css/app2.css' from CssLinkResourceTransformer instead of 'app2.css'. The chain will return null and URL won't be transformed.

CssLinkResourceTransformer should rely on the same mechanism as ResourceUrlProvider.


Affects: 4.1 RC2

Referenced from: commits 125ae99

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 3, 2014

Guillaume DROUET commented

It works fine now :)

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 3, 2014

Brian Clozel commented

Great!
Note that using absolute paths in CSS files is now possible, but relative paths should be used in priority here. Client build tools prefer relative paths to concatenate and minify resources (in your case, this point is not relevant). But still, if you're deploying an application where servlet or context paths change, those absolute paths will change as well...

Thanks for all your feedback, we really appreciate it.

@spring-projects-issues spring-projects-issues added type: bug in: web labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.1 GA milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web type: bug
Projects
None yet
Development

No branches or pull requests

2 participants