DATAREST-276 - Yet another round of trailing slash handling.
We need to proactively strip trailing slashes during base URI handling as even on a successful match (which previously left trailing slashes intact) this might subsequently on the resolving of the repository metadata when evaluating the left-over lookup path against the @RequestMapping methods (which keeps trailing slashes).
This commit is contained in:
@@ -103,6 +103,8 @@ public class BaseUri {
|
||||
|
||||
Assert.notNull(lookupPath, "Lookup path must not be null!");
|
||||
|
||||
lookupPath = trimTrailingCharacter(lookupPath, '/');
|
||||
|
||||
if (!baseUri.isAbsolute()) {
|
||||
|
||||
String uri = baseUri.toString();
|
||||
|
||||
@@ -94,6 +94,6 @@ public class ResourceMetadataHandlerMethodArgumentResolver implements HandlerMet
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
throw new IllegalArgumentException(String.format("Could not resolve repository metadata for %s.", repositoryKey));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class BaseUriUnitTests {
|
||||
BaseUri uri = new BaseUri(URI.create("foo/"));
|
||||
|
||||
assertThat(uri.getRepositoryLookupPath("/foo"), isEmptyString());
|
||||
assertThat(uri.getRepositoryLookupPath("/foo/"), is("/"));
|
||||
assertThat(uri.getRepositoryLookupPath("/foo/"), isEmptyString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ public class BaseUriUnitTests {
|
||||
BaseUri uri = new BaseUri(URI.create("/foo"));
|
||||
|
||||
assertThat(uri.getRepositoryLookupPath("/foo"), isEmptyString());
|
||||
assertThat(uri.getRepositoryLookupPath("/foo/"), is("/"));
|
||||
assertThat(uri.getRepositoryLookupPath("/foo/"), isEmptyString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,8 +83,8 @@ public class BaseUriUnitTests {
|
||||
BaseUri uri = new BaseUri(URI.create("http://localhost:8080/foo/"));
|
||||
|
||||
assertThat(uri.getRepositoryLookupPath("/foo"), isEmptyString());
|
||||
assertThat(uri.getRepositoryLookupPath("/foo/"), is("/"));
|
||||
assertThat(uri.getRepositoryLookupPath("/foo/"), isEmptyString());
|
||||
assertThat(uri.getRepositoryLookupPath("/foo/people"), is("/people"));
|
||||
assertThat(uri.getRepositoryLookupPath("/foo/people/"), is("/people/"));
|
||||
assertThat(uri.getRepositoryLookupPath("/foo/people/"), is("/people"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user