diff --git a/rewrite-core/src/main/java/org/openrewrite/PathUtils.java b/rewrite-core/src/main/java/org/openrewrite/PathUtils.java index ad7138159de..efcc738ba4e 100755 --- a/rewrite-core/src/main/java/org/openrewrite/PathUtils.java +++ b/rewrite-core/src/main/java/org/openrewrite/PathUtils.java @@ -136,7 +136,7 @@ private static boolean matchesGlob(String pattern, String path) { } if (pathIdxStart > pathIdxEnd) { // Path exhausted - for (int i = pattIdxStart; i < pattIdxEnd; i++) { + for (int i = pattIdxStart; i <= pattIdxEnd; i++) { if (!pattTokens[i].equals("**")) { return false; } diff --git a/rewrite-core/src/test/java/org/openrewrite/PathUtilsTest.java b/rewrite-core/src/test/java/org/openrewrite/PathUtilsTest.java index 253762c8b8e..cf599619497 100644 --- a/rewrite-core/src/test/java/org/openrewrite/PathUtilsTest.java +++ b/rewrite-core/src/test/java/org/openrewrite/PathUtilsTest.java @@ -94,6 +94,8 @@ void globMatching() { assertThat(matchesGlob(path("a/b/test.txt"), "a/**/*.txt")).isTrue(); assertThat(matchesGlob(path("a/b/test.txt"), "a/**/test.*")).isTrue(); assertThat(matchesGlob(path("a/b/test.txt"), "a/**/*.*")).isTrue(); + assertThat(matchesGlob(path("a-test/a-test/test.txt"), "**/*-test/*-test/test.txt")).isTrue(); + assertThat(matchesGlob(path("a-test/test.txt"), "**/*-test/*-test/test.txt")).isFalse(); } private static Path path(String path) {