diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/BaseUri.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/BaseUri.java index f1cc177cc..bbdfce1b2 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/BaseUri.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/BaseUri.java @@ -111,6 +111,9 @@ public class BaseUri { Assert.notNull(lookupPath, "Lookup path must not be null!"); + // Temporary fix for SPR-13455 + lookupPath = lookupPath.replaceAll("//", "/"); + lookupPath = trimTrailingCharacter(lookupPath, '/'); if (!baseUri.isAbsolute()) { diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/BaseUriUnitTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/BaseUriUnitTests.java index a8bbf6416..3fade4198 100644 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/BaseUriUnitTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/BaseUriUnitTests.java @@ -87,4 +87,13 @@ public class BaseUriUnitTests { assertThat(uri.getRepositoryLookupPath("/foo/people"), is("/people")); assertThat(uri.getRepositoryLookupPath("/foo/people/"), is("/people")); } + + /** + * @see DATAREST-674 + * @see SPR-13455 + */ + @Test + public void repositoryLookupPathHandlesDoubleSlashes() { + assertThat(BaseUri.NONE.getRepositoryLookupPath("/books//1"), is("/books/1")); + } }