Merge branch '1.4.x'

This commit is contained in:
Spencer Gibb
2018-02-01 19:22:06 -05:00
3 changed files with 18 additions and 4 deletions

View File

@@ -150,10 +150,10 @@ working copy as a cache.
This repository implementation maps the `{label}` parameter of the
HTTP resource to a git label (commit id, branch name or tag). If the
git branch or tag name contains a slash ("/") then the label in the
HTTP URL should be specified with the special string "(\_)" instead (to
HTTP URL should be specified with the special string "(_)" instead (to
avoid ambiguity with other URL paths). For example, if the label is
`foo/bar`, replacing the slash would result in a label that looks like
`foo(_)bar`. The inclusion of the special string "(\_)" can also be
`foo(_)bar`. The inclusion of the special string "(_)" can also be
applied to the `{application}` parameter. Be careful with the brackets
in the URL if you are using a command line client like curl (e.g.
escape them from the shell with quotes '').
@@ -179,7 +179,7 @@ spring:
or a "one repo per profile" policy using a similar pattern but with
`{profile}`.
Additionally, using the special string "(\_)" within your
Additionally, using the special string "(_)" within your
`{application}` parameters can enable support for multiple
organizations (for example):
@@ -194,7 +194,7 @@ spring:
----
where `{application}` is provided at request time in the format
"organization(\_)application".
"organization(_)application".
===== Pattern Matching and Multiple Repositories

View File

@@ -99,6 +99,11 @@ public class EnvironmentController {
@RequestMapping("/{name}/{profiles}/{label:.*}")
public Environment labelled(@PathVariable String name, @PathVariable String profiles,
@PathVariable String label) {
if (name != null && name.contains("(_)")) {
// "(_)" is uncommon in a git repo name, but "/" cannot be matched
// by Spring MVC
name = name.replace("(_)", "/");
}
if (label != null && label.contains("(_)")) {
// "(_)" is uncommon in a git branch name, but "/" cannot be matched
// by Spring MVC

View File

@@ -140,6 +140,15 @@ public class EnvironmentControllerIntegrationTests {
.andExpect(MockMvcResultMatchers.content().string(Matchers.containsString("\"propertySources\":")));
}
@Test
public void environmentWithApplicationContainingSlash() throws Exception {
Mockito.when(this.repository.findOne("foo/app", "default", null))
.thenReturn(new Environment("foo/app", "default"));
this.mvc.perform(MockMvcRequestBuilders.get("/foo(_)app/default"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.content().string(Matchers.containsString("\"propertySources\":")));
}
@Configuration
@EnableWebMvc
@Import(PropertyPlaceholderAutoConfiguration.class)