Skip to content

Commit e712b08

Browse files
committed
add support for exact and /prefix/* matching
1 parent 7d55536 commit e712b08

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.example.server;
2+
3+
public final class RoutePattern {
4+
5+
private RoutePattern() {}
6+
7+
public static boolean matches(String pattern, String path) {
8+
if (pattern == null || path == null) return false;
9+
10+
if (pattern.endsWith("/*")) {
11+
String prefix = pattern.substring(0, pattern.length() - 1);
12+
return path.startsWith(prefix);
13+
}
14+
15+
return pattern.equals(path);
16+
}
17+
}

0 commit comments

Comments
 (0)