-
Couldn't load subscription status.
- Fork 38.8k
Description
Oliver Lehmann opened SPR-13435 and commented
When running a Unittest with MockHttpServletRequestBuilder I have the following URI for example:
/test//currentlyValid/0
After Calling MockMvcRequestBuilders.get(uri); The uri inside the returning builder is set to
/test/currentlyValid/0
The double slash was replaced by a single slash!
This was done by the following code in org.springframework.web.util.UriComponentsBuilder.FullPathComponentBuilder
public PathComponent build() {
if (this.path.length() == 0) {
return null;
}
String path = this.path.toString();
while (true) {
int index = path.indexOf("//");
if (index == -1) {
break;
}
path = path.substring(0, index) + path.substring(index + 1);
}
return new HierarchicalUriComponents.FullPathComponent(path);
}
What is the point in replacing double slashes by a single slash? How am I supposed to test usecases with optional path variables?
For me, this feels like a bug to report....
Affects: 4.1.7
Referenced from: commits df171ff