|
74 | 74 | * @author Arjen Poutsma |
75 | 75 | * @author Sam Brannen |
76 | 76 | * @author Kamill Sokol |
77 | | - * @author Réda Housni Alaoui |
78 | 77 | * @since 6.2 |
79 | 78 | * @param <B> a self reference to the builder type |
80 | 79 | */ |
@@ -855,17 +854,14 @@ private void updatePathRequestProperties(MockHttpServletRequest request, String |
855 | 854 | request.setContextPath(this.contextPath); |
856 | 855 | request.setServletPath(this.servletPath); |
857 | 856 |
|
858 | | - String pathInfoToUse = this.pathInfo; |
859 | | - if ("".equals(pathInfoToUse)) { |
860 | | - if (!requestUri.startsWith(this.contextPath + this.servletPath)) { |
861 | | - throw new IllegalArgumentException( |
862 | | - "Invalid servlet path [" + this.servletPath + "] for request URI [" + requestUri + "]"); |
863 | | - } |
864 | | - String extraPath = requestUri.substring(this.contextPath.length() + this.servletPath.length()); |
865 | | - pathInfoToUse = (StringUtils.hasText(extraPath) ? |
866 | | - UrlPathHelper.defaultInstance.decodeRequestString(request, extraPath) : null); |
| 857 | + String path = this.pathInfo; |
| 858 | + if ("".equals(path)) { |
| 859 | + Assert.isTrue(requestUri.startsWith(this.contextPath + this.servletPath), |
| 860 | + () -> "Invalid servlet path [" + this.servletPath + "] for request URI [" + requestUri + "]"); |
| 861 | + String other = requestUri.substring(this.contextPath.length() + this.servletPath.length()); |
| 862 | + path = (StringUtils.hasText(other) ? UrlPathHelper.defaultInstance.decodeRequestString(request, other) : null); |
867 | 863 | } |
868 | | - request.setPathInfo(pathInfoToUse); |
| 864 | + request.setPathInfo(path); |
869 | 865 | } |
870 | 866 |
|
871 | 867 | private void addRequestParams(MockHttpServletRequest request, MultiValueMap<String, String> map) { |
|
0 commit comments