Clean Windows paths before guessing the service name
When encountering windows paths when running in native profile, services names would not be extracted correctly due to different path separators. Now they are normalized before being used for service name guessing. Fixes #531
This commit is contained in:
@@ -111,7 +111,7 @@ public class PropertyPathEndpoint
|
||||
Set<String> services = new LinkedHashSet<>();
|
||||
if (path != null) {
|
||||
String stem = StringUtils
|
||||
.stripFilenameExtension(StringUtils.getFilename(path));
|
||||
.stripFilenameExtension(StringUtils.getFilename(StringUtils.cleanPath(path)));
|
||||
// TODO: correlate with service registry
|
||||
int index = stem.indexOf("-");
|
||||
while (index >= 0) {
|
||||
|
||||
@@ -86,6 +86,15 @@ public class PropertyPathEndpointTests {
|
||||
.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotifyOneWithWindowsPath() throws Exception {
|
||||
assertEquals("[foo]",
|
||||
this.endpoint
|
||||
.notifyByPath(new HttpHeaders(), Collections
|
||||
.<String, Object> singletonMap("path", "C:\\config\\foo.yml"))
|
||||
.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotifyOneWithProfile() throws Exception {
|
||||
assertEquals("[foo:local, foo-local]",
|
||||
|
||||
Reference in New Issue
Block a user