Skip to content

Commit 9334691

Browse files
committed
Fix RoutePattern wildcard to match base path (/api/* matches /api)
1 parent aba21a5 commit 9334691

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/org/example/server/RoutePattern.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ public static boolean matches(String pattern, String path) {
88
if (pattern == null || path == null) return false;
99

1010
if (pattern.endsWith("/*")) {
11-
String prefix = pattern.substring(0, pattern.length() - 1);
12-
return path.startsWith(prefix);
11+
String base = pattern.substring(0, pattern.length() - 2); // drop "/*"
12+
return path.equals(base) || path.startsWith(base + "/");
1313
}
1414

1515
return pattern.equals(path);
1616
}
17-
}
17+
}

0 commit comments

Comments
 (0)