Skip to content

Commit 293188c

Browse files
committed
Consistent non-use of firstIndex 0 in PatternMatchUtils
Closes gh-22837
1 parent 9674ce4 commit 293188c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

spring-core/src/main/java/org/springframework/util/PatternMatchUtils.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,15 +39,17 @@ public static boolean simpleMatch(@Nullable String pattern, @Nullable String str
3939
if (pattern == null || str == null) {
4040
return false;
4141
}
42+
4243
int firstIndex = pattern.indexOf('*');
4344
if (firstIndex == -1) {
4445
return pattern.equals(str);
4546
}
47+
4648
if (firstIndex == 0) {
4749
if (pattern.length() == 1) {
4850
return true;
4951
}
50-
int nextIndex = pattern.indexOf('*', firstIndex + 1);
52+
int nextIndex = pattern.indexOf('*', 1);
5153
if (nextIndex == -1) {
5254
return str.endsWith(pattern.substring(1));
5355
}
@@ -64,6 +66,7 @@ public static boolean simpleMatch(@Nullable String pattern, @Nullable String str
6466
}
6567
return false;
6668
}
69+
6770
return (str.length() >= firstIndex &&
6871
pattern.substring(0, firstIndex).equals(str.substring(0, firstIndex)) &&
6972
simpleMatch(pattern.substring(firstIndex), str.substring(firstIndex)));

0 commit comments

Comments
 (0)