Accept (_) escape for / in environment controller
Fixes gh-264
This commit is contained in:
@@ -65,6 +65,11 @@ public class ResourceController {
|
||||
@PathVariable String profile, @PathVariable String label,
|
||||
@PathVariable String path) throws IOException {
|
||||
StandardEnvironment environment = new StandardEnvironment();
|
||||
if (label != null && label.contains("(_)")) {
|
||||
// "(_)" is uncommon in a git branch name, but "/" cannot be matched
|
||||
// by Spring MVC
|
||||
label = label.replace("(_)", "/");
|
||||
}
|
||||
environment.getPropertySources().addAfter(
|
||||
StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME,
|
||||
new EnvironmentPropertySource(
|
||||
|
||||
@@ -78,4 +78,11 @@ public class ResourceControllerTests {
|
||||
assertEquals("foo: ${foo}", resource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void labelWithSlash() throws Exception {
|
||||
this.environmentRepository.setSearchLocations("classpath:/test");
|
||||
String resource = this.controller.resolve("foo", "bar", "dev(_)spam", "foo.txt");
|
||||
assertEquals("foo: dev_bar/spam", resource);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
foo: dev_bar/spam
|
||||
Reference in New Issue
Block a user