|
|
|
@ -21,6 +21,7 @@ import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.util.PathMatcher; |
|
|
|
import org.springframework.util.PathMatcher; |
|
|
|
|
|
|
|
import static org.springframework.util.StringUtils.hasLength; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Represents a parsed path pattern. Includes a chain of path elements |
|
|
|
* Represents a parsed path pattern. Includes a chain of path elements |
|
|
|
@ -132,9 +133,9 @@ public class PathPattern implements Comparable<PathPattern> { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean matches(String path) { |
|
|
|
public boolean matches(String path) { |
|
|
|
if (head == null) { |
|
|
|
if (head == null) { |
|
|
|
return (path == null) || (path.length() == 0); |
|
|
|
return !hasLength(path); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (path == null || path.length() == 0) { |
|
|
|
else if (!hasLength(path)) { |
|
|
|
if (head instanceof WildcardTheRestPathElement || head instanceof CaptureTheRestPathElement) { |
|
|
|
if (head instanceof WildcardTheRestPathElement || head instanceof CaptureTheRestPathElement) { |
|
|
|
path = ""; // Will allow CaptureTheRest to bind the variable to empty
|
|
|
|
path = ""; // Will allow CaptureTheRest to bind the variable to empty
|
|
|
|
} |
|
|
|
} |
|
|
|
@ -152,9 +153,9 @@ public class PathPattern implements Comparable<PathPattern> { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean matchStart(String path) { |
|
|
|
public boolean matchStart(String path) { |
|
|
|
if (head == null) { |
|
|
|
if (head == null) { |
|
|
|
return (path == null || path.length() == 0); |
|
|
|
return !hasLength(path); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (path == null || path.length() == 0) { |
|
|
|
else if (!hasLength(path)) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
MatchingContext matchingContext = new MatchingContext(path, false); |
|
|
|
MatchingContext matchingContext = new MatchingContext(path, false); |
|
|
|
@ -172,7 +173,7 @@ public class PathPattern implements Comparable<PathPattern> { |
|
|
|
return matchingContext.getExtractedVariables(); |
|
|
|
return matchingContext.getExtractedVariables(); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
if (path == null || path.length() == 0) { |
|
|
|
if (!hasLength(path)) { |
|
|
|
return NO_VARIABLES_MAP; |
|
|
|
return NO_VARIABLES_MAP; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
@ -434,15 +435,15 @@ public class PathPattern implements Comparable<PathPattern> { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public String combine(String pattern2string) { |
|
|
|
public String combine(String pattern2string) { |
|
|
|
// If one of them is empty the result is the other. If both empty the result is ""
|
|
|
|
// If one of them is empty the result is the other. If both empty the result is ""
|
|
|
|
if (patternString == null || patternString.length() == 0) { |
|
|
|
if (!hasLength(patternString)) { |
|
|
|
if (pattern2string == null || pattern2string.length() == 0) { |
|
|
|
if (!hasLength(pattern2string)) { |
|
|
|
return ""; |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
return pattern2string; |
|
|
|
return pattern2string; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if (pattern2string == null || pattern2string.length() == 0) { |
|
|
|
else if (!hasLength(pattern2string)) { |
|
|
|
return patternString; |
|
|
|
return patternString; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|