Enforce cleaned URL for root resource from ClassLoader
Closes gh-32828
This commit is contained in:
parent
70886e32c0
commit
2270df515b
|
@ -423,6 +423,17 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
|||
}
|
||||
}
|
||||
else {
|
||||
String urlString = url.toString();
|
||||
String cleanedPath = StringUtils.cleanPath(urlString);
|
||||
if (!cleanedPath.equals(urlString)) {
|
||||
// Prefer cleaned URL, aligned with UrlResource#createRelative(String)
|
||||
try {
|
||||
return new UrlResource(ResourceUtils.toURI(cleanedPath));
|
||||
}
|
||||
catch (URISyntaxException | MalformedURLException ex) {
|
||||
// Fallback to regular URL construction below...
|
||||
}
|
||||
}
|
||||
return new UrlResource(url);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue