File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed
main/java/org/springframework/util
test/java/org/springframework/util Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2018 the original author or authors.
2
+ * Copyright 2002-2019 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -169,7 +169,21 @@ private void deactivatePatternCache() {
169
169
170
170
@ Override
171
171
public boolean isPattern (String path ) {
172
- return (path .indexOf ('*' ) != -1 || path .indexOf ('?' ) != -1 );
172
+ boolean uriVar = false ;
173
+ for (int i = 0 ; i < path .length (); i ++) {
174
+ char c = path .charAt (i );
175
+ if (c == '*' || c == '?' ) {
176
+ return true ;
177
+ }
178
+ if (c == '{' ) {
179
+ uriVar = true ;
180
+ continue ;
181
+ }
182
+ if (c == '}' && uriVar ) {
183
+ return true ;
184
+ }
185
+ }
186
+ return false ;
173
187
}
174
188
175
189
@ Override
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2016 the original author or authors.
2
+ * Copyright 2002-2019 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -681,4 +681,14 @@ public void extensionMappingWithDotPathSeparator() {
681
681
"/*.html.hotel.*" , pathMatcher .combine ("/*.html" , "hotel.*" ));
682
682
}
683
683
684
+ @ Test // gh-22959
685
+ public void isPattern () {
686
+ assertTrue (pathMatcher .isPattern ("/test/*" ));
687
+ assertTrue (pathMatcher .isPattern ("/test/**/name" ));
688
+ assertTrue (pathMatcher .isPattern ("/test?" ));
689
+ assertTrue (pathMatcher .isPattern ("/test/{name}" ));
690
+ assertFalse (pathMatcher .isPattern ("/test/name" ));
691
+ assertFalse (pathMatcher .isPattern ("/test/foo{bar" ));
692
+ }
693
+
684
694
}
You can’t perform that action at this time.
0 commit comments