parent
84200f3141
commit
7779aa3487
|
@ -169,7 +169,7 @@ public class AntPathMatcher implements PathMatcher {
|
|||
|
||||
@Override
|
||||
public boolean isPattern(String path) {
|
||||
if(path == null) {
|
||||
if (path == null) {
|
||||
return false;
|
||||
}
|
||||
boolean uriVar = false;
|
||||
|
@ -202,7 +202,7 @@ public class AntPathMatcher implements PathMatcher {
|
|||
/**
|
||||
* Actually match the given {@code path} against the given {@code pattern}.
|
||||
* @param pattern the pattern to match against
|
||||
* @param path the path String to test
|
||||
* @param path the path to test
|
||||
* @param fullMatch whether a full pattern match is required (else a pattern match
|
||||
* as far as the given base path goes is sufficient)
|
||||
* @return {@code true} if the supplied {@code path} matched, {@code false} if it didn't
|
||||
|
@ -210,7 +210,7 @@ public class AntPathMatcher implements PathMatcher {
|
|||
protected boolean doMatch(String pattern, String path, boolean fullMatch,
|
||||
@Nullable Map<String, String> uriTemplateVariables) {
|
||||
|
||||
if (path == null || path.startsWith(this.pathSeparator) != pattern.startsWith(this.pathSeparator)) {
|
||||
if ((path == null) || (path.startsWith(this.pathSeparator) != pattern.startsWith(this.pathSeparator))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ public class AntPathMatcher implements PathMatcher {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tokenize the given path String into parts, based on this matcher's settings.
|
||||
* Tokenize the given path into parts, based on this matcher's settings.
|
||||
* @param path the path to tokenize
|
||||
* @return the tokenized path parts
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -41,7 +41,7 @@ public interface PathMatcher {
|
|||
* <p>If the return value is {@code false}, then the {@link #match}
|
||||
* method does not have to be used because direct equality comparisons
|
||||
* on the static path Strings will lead to the same result.
|
||||
* @param path the path String to check
|
||||
* @param path the path to check
|
||||
* @return {@code true} if the given {@code path} represents a pattern
|
||||
*/
|
||||
boolean isPattern(String path);
|
||||
|
@ -50,7 +50,7 @@ public interface PathMatcher {
|
|||
* Match the given {@code path} against the given {@code pattern},
|
||||
* according to this PathMatcher's matching strategy.
|
||||
* @param pattern the pattern to match against
|
||||
* @param path the path String to test
|
||||
* @param path the path to test
|
||||
* @return {@code true} if the supplied {@code path} matched,
|
||||
* {@code false} if it didn't
|
||||
*/
|
||||
|
@ -62,7 +62,7 @@ public interface PathMatcher {
|
|||
* <p>Determines whether the pattern at least matches as far as the given base
|
||||
* path goes, assuming that a full path may then match as well.
|
||||
* @param pattern the pattern to match against
|
||||
* @param path the path String to test
|
||||
* @param path the path to test
|
||||
* @return {@code true} if the supplied {@code path} matched,
|
||||
* {@code false} if it didn't
|
||||
*/
|
||||
|
|
|
@ -130,7 +130,10 @@ public class AntPathMatcherTests {
|
|||
assertThat(pathMatcher.match("", "")).isTrue();
|
||||
|
||||
assertThat(pathMatcher.match("/{bla}.*", "/testing.html")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchWithNullPath() {
|
||||
assertThat(pathMatcher.match("/test", null)).isFalse();
|
||||
assertThat(pathMatcher.match("/", null)).isFalse();
|
||||
assertThat(pathMatcher.match("/", null)).isFalse();
|
||||
|
@ -146,7 +149,7 @@ public class AntPathMatcherTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void withMatchStart() {
|
||||
public void matchStart() {
|
||||
// test exact matching
|
||||
assertThat(pathMatcher.matchStart("test", "test")).isTrue();
|
||||
assertThat(pathMatcher.matchStart("/test", "/test")).isTrue();
|
||||
|
@ -691,8 +694,13 @@ public class AntPathMatcherTests {
|
|||
assertThat(pathMatcher.isPattern("/test/**/name")).isTrue();
|
||||
assertThat(pathMatcher.isPattern("/test?")).isTrue();
|
||||
assertThat(pathMatcher.isPattern("/test/{name}")).isTrue();
|
||||
|
||||
assertThat(pathMatcher.isPattern("/test/name")).isFalse();
|
||||
assertThat(pathMatcher.isPattern("/test/foo{bar")).isFalse();
|
||||
}
|
||||
|
||||
@Test // gh-23297
|
||||
public void isPatternWithNullPath() {
|
||||
assertThat(pathMatcher.isPattern(null)).isFalse();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue