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 8bce1fc59..7208af54a 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 @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -111,7 +111,11 @@ public class BaseUri { Assert.notNull(lookupPath, "Lookup path must not be null!"); + // Temporary fix for SPR-13455 + lookupPath = lookupPath.replaceAll("//", "/"); + lookupPath = lookupPath.contains("{") ? lookupPath.substring(0, lookupPath.indexOf('{')) : lookupPath; + 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 7bbae6fe9..521e6c703 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 @@ -111,4 +111,13 @@ public class BaseUriUnitTests { ServletWebRequest request = new ServletWebRequest(new MockHttpServletRequest("GET", "/foo/bar{?projection}")); assertThat(uri.getRepositoryLookupPath(request), is("/bar")); } + + /** + * @see DATAREST-674 + * @see SPR-13455 + */ + @Test + public void repositoryLookupPathHandlesDoubleSlashes() { + assertThat(BaseUri.NONE.getRepositoryLookupPath("/books//1"), is("/books/1")); + } }