mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Enfoce single version removal in content versioning
Prior to this commit, content based version strategies would remove all instances of the version string in the request path when trying to resolve the original resource with the chain. This can cause issues in rare cases where there is a collision between the content version and some other version string in the request path. Because this strategy is based on the contents of the file itself, we should only remove the last instance of the version string and then attempt to resolve the original file. Fixes gh-36698
This commit is contained in:
+8
@@ -63,6 +63,14 @@ class ContentBasedVersionStrategyTests {
|
||||
assertThat(this.versionStrategy.removeVersion(String.format(file, "-", hash), hash)).isEqualTo(String.format(file, "", ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
void removeVersionOnlyOnce() {
|
||||
String hash = "sha";
|
||||
String file = "font-awesome/css%s%s/font-awesome.min%s%s.css";
|
||||
|
||||
assertThat(this.versionStrategy.removeVersion(String.format(file, "-", hash, "-", hash), hash)).isEqualTo(String.format(file, "-", hash, "", ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getResourceVersion() throws IOException {
|
||||
Resource expected = new ClassPathResource("test/bar.css", getClass());
|
||||
|
||||
Reference in New Issue
Block a user