|
|
|
|
@ -55,8 +55,7 @@ class DefaultRequestPath implements RequestPath {
@@ -55,8 +55,7 @@ class DefaultRequestPath implements RequestPath {
|
|
|
|
|
return PathContainer.parseUrlPath(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Assert.isTrue(contextPath.startsWith("/") && !contextPath.endsWith("/") && |
|
|
|
|
path.value().startsWith(contextPath), "Invalid contextPath: " + contextPath); |
|
|
|
|
validateContextPath(path.value(), contextPath); |
|
|
|
|
|
|
|
|
|
int length = contextPath.length(); |
|
|
|
|
int counter = 0; |
|
|
|
|
@ -70,8 +69,24 @@ class DefaultRequestPath implements RequestPath {
@@ -70,8 +69,24 @@ class DefaultRequestPath implements RequestPath {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Should not happen..
|
|
|
|
|
throw new IllegalStateException("Failed to initialize contextPath='" + contextPath + "'" + |
|
|
|
|
" given path='" + path.value() + "'"); |
|
|
|
|
throw new IllegalStateException("Failed to initialize contextPath '" + contextPath + "'" + |
|
|
|
|
" for requestPath '" + path.value() + "'"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void validateContextPath(String fullPath, String contextPath) { |
|
|
|
|
int length = contextPath.length(); |
|
|
|
|
if (contextPath.charAt(0) != '/' || contextPath.charAt(length - 1) == '/') { |
|
|
|
|
throw new IllegalArgumentException("Invalid contextPath: '" + contextPath + "': " + |
|
|
|
|
"must start with '/' and not end with '/'"); |
|
|
|
|
} |
|
|
|
|
if (!fullPath.startsWith(contextPath)) { |
|
|
|
|
throw new IllegalArgumentException("Invalid contextPath '" + contextPath + "': " + |
|
|
|
|
"must match the start of requestPath: '" + fullPath + "'"); |
|
|
|
|
} |
|
|
|
|
if (fullPath.length() > length && fullPath.charAt(length) != '/') { |
|
|
|
|
throw new IllegalArgumentException("Invalid contextPath '" + contextPath + "': " + |
|
|
|
|
"must match to full path segments for requestPath: '" + fullPath + "'"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static PathContainer extractPathWithinApplication(PathContainer fullPath, PathContainer contextPath) { |
|
|
|
|
|