Skip to content

Commit

Permalink
fix for issue #279
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudenw authored and slachiewicz committed Nov 5, 2024
1 parent 1f55ae1 commit 46d98a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/codehaus/plexus/util/SelectorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static boolean matchPatternStart(String pattern, String str, boolean isCa
}

public static boolean isAntPrefixedPattern(String pattern) {
return pattern.length() > (ANT_HANDLER_PREFIX.length() + PATTERN_HANDLER_SUFFIX.length() + 1)
return pattern.length() > (ANT_HANDLER_PREFIX.length() + PATTERN_HANDLER_SUFFIX.length())
&& pattern.startsWith(ANT_HANDLER_PREFIX)
&& pattern.endsWith(PATTERN_HANDLER_SUFFIX);
}
Expand Down Expand Up @@ -254,7 +254,7 @@ private static String toOSRelatedPath(String pattern, String separator) {
}

public static boolean isRegexPrefixedPattern(String pattern) {
return pattern.length() > (REGEX_HANDLER_PREFIX.length() + PATTERN_HANDLER_SUFFIX.length() + 1)
return pattern.length() > (REGEX_HANDLER_PREFIX.length() + PATTERN_HANDLER_SUFFIX.length())
&& pattern.startsWith(REGEX_HANDLER_PREFIX)
&& pattern.endsWith(PATTERN_HANDLER_SUFFIX);
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/codehaus/plexus/util/SelectorUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void testExtractPattern() {
*/
@Test
public void testIsAntPrefixedPattern() {
assertFalse(SelectorUtils.isAntPrefixedPattern("%ant[A]")); // single char not allowed
assertTrue(SelectorUtils.isAntPrefixedPattern("%ant[A]")); // single char not allowed
assertTrue(SelectorUtils.isAntPrefixedPattern("%ant[AB]"));
assertFalse(SelectorUtils.isAntPrefixedPattern("%ant[]"));
assertFalse(SelectorUtils.isAntPrefixedPattern("*"));
Expand All @@ -60,7 +60,7 @@ public void testIsAntPrefixedPattern() {
*/
@Test
public void testIsRegexPrefixedPattern() {
assertFalse(SelectorUtils.isRegexPrefixedPattern("%regex[A]")); // single char not allowed
assertTrue(SelectorUtils.isRegexPrefixedPattern("%regex[A]")); // single char not allowed
assertTrue(SelectorUtils.isRegexPrefixedPattern("%regex[.*]"));
assertFalse(SelectorUtils.isRegexPrefixedPattern("%regex[]"));
assertFalse(SelectorUtils.isRegexPrefixedPattern("*"));
Expand Down

0 comments on commit 46d98a6

Please sign in to comment.