Merge branch '6.1.x'
This commit is contained in:
@@ -445,12 +445,18 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
|||||||
if (!cleanedPath.equals(urlString)) {
|
if (!cleanedPath.equals(urlString)) {
|
||||||
// Prefer cleaned URL, aligned with UrlResource#createRelative(String)
|
// Prefer cleaned URL, aligned with UrlResource#createRelative(String)
|
||||||
try {
|
try {
|
||||||
return new UrlResource(ResourceUtils.toURI(cleanedPath));
|
// Cannot test for URLStreamHandler directly: URL equality for same String
|
||||||
|
// in order to find out whether original URL uses default URLStreamHandler.
|
||||||
|
if (ResourceUtils.toURL(urlString).equals(url)) {
|
||||||
|
// Plain URL with default URLStreamHandler -> replace with cleaned path.
|
||||||
|
return new UrlResource(ResourceUtils.toURI(cleanedPath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (URISyntaxException | MalformedURLException ex) {
|
catch (URISyntaxException | MalformedURLException ex) {
|
||||||
// Fallback to regular URL construction below...
|
// Fallback to regular URL construction below...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Retain original URL instance, potentially including custom URLStreamHandler.
|
||||||
return new UrlResource(url);
|
return new UrlResource(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user