mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Do not include URL hash in resource paths
When getting the lookup path of a resource, both query params and hashes should be removed from the request path. This commit fixes the public path resolution for paths like `/resources/main.svg#icon-hamburgermenu`. Issue: SPR-14928
This commit is contained in:
+8
-3
@@ -73,13 +73,18 @@ public class ResourceUrlProviderTests {
|
||||
}
|
||||
|
||||
@Test // SPR-13374
|
||||
public void getStaticResourceUrlRequestWithRequestParams() {
|
||||
public void getStaticResourceUrlRequestWithQueryOrHash() {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.setContextPath("/");
|
||||
request.setRequestURI("/");
|
||||
|
||||
String url = this.urlProvider.getForRequestUrl(request, "/resources/foo.css?foo=bar&url=http://example.org");
|
||||
assertEquals("/resources/foo.css?foo=bar&url=http://example.org", url);
|
||||
String url = "/resources/foo.css?foo=bar&url=http://example.org";
|
||||
String resolvedUrl = this.urlProvider.getForRequestUrl(request, url);
|
||||
assertEquals("/resources/foo.css?foo=bar&url=http://example.org", resolvedUrl);
|
||||
|
||||
url = "/resources/foo.css#hash";
|
||||
resolvedUrl = this.urlProvider.getForRequestUrl(request, url);
|
||||
assertEquals("/resources/foo.css#hash", resolvedUrl);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user