UrlHandlerFilter ignores trailing slash in contextPath

Closes gh-33565
This commit is contained in:
rstoyanchev
2024-09-18 22:37:21 +01:00
parent e587753b1d
commit 2090ece62a
4 changed files with 18 additions and 12 deletions

View File

@@ -278,7 +278,7 @@ public final class UrlHandlerFilter extends OncePerRequestFilter {
@Override
public boolean canHandle(HttpServletRequest request, RequestPath path) {
List<PathContainer.Element> elements = path.elements();
List<PathContainer.Element> elements = path.pathWithinApplication().elements();
return (elements.size() > 1 && elements.get(elements.size() - 1).value().equals("/"));
}

View File

@@ -253,7 +253,8 @@ public final class UrlHandlerFilter implements WebFilter {
@Override
public boolean canHandle(ServerWebExchange exchange) {
List<PathContainer.Element> elements = exchange.getRequest().getPath().elements();
ServerHttpRequest request = exchange.getRequest();
List<PathContainer.Element> elements = request.getPath().pathWithinApplication().elements();
return (elements.size() > 1 && elements.get(elements.size() - 1).value().equals("/"));
}