PathPattern#matchAndExtract minor refactoring
Consistent behavior with matches(PathContainer), the two had slightly different logic for handling of empty paths. Make matchAndExtract independantly usable without the need to call matches(PathContainer) first. Essentially no longer raising ISE if the pattern doesn't match but simply returning null.
This commit is contained in:
@@ -343,10 +343,10 @@ public abstract class RequestPredicates {
|
||||
@Override
|
||||
public boolean test(ServerRequest request) {
|
||||
PathContainer pathContainer = request.pathContainer();
|
||||
boolean match = this.pattern.matches(pathContainer);
|
||||
traceMatch("Pattern", this.pattern.getPatternString(), request.path(), match);
|
||||
if (match) {
|
||||
mergeTemplateVariables(request, this.pattern.matchAndExtract(pathContainer).getUriVariables());
|
||||
PathPattern.PathMatchInfo info = this.pattern.matchAndExtract(pathContainer);
|
||||
traceMatch("Pattern", this.pattern.getPatternString(), request.path(), info != null);
|
||||
if (info != null) {
|
||||
mergeTemplateVariables(request, info.getUriVariables());
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user