Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support wildcard in path template. #3559

Merged
merged 4 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ static PathMatcher compile(CharSequence pattern) {
paramCounter++;
}
break;
case '*':
klustria marked this conversation as resolved.
Show resolved Hide resolved
if (!optionalSequence) {
klustria marked this conversation as resolved.
Show resolved Hide resolved
isRegexp = true;
regexp.append(".*?");
}
break;
default:
shouldContinue = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.Map;
import java.util.stream.Collectors;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
Expand All @@ -32,7 +31,6 @@
/**
* The PathTemplateTest.
*/
@Disabled
public class PathPatternTest {

private String normalize(String path) {
Expand Down Expand Up @@ -229,6 +227,20 @@ public void testGreedyParams() throws Exception {
assertMatchWithParams("/foo/bar/baz/xxx", "/foo/{+}/xxx");
}

@Test
public void testWildCard() throws Exception {
assertMatch("/foo/bar", "/foo*");
assertMatch("/foo/bar", "/foo/*");
assertMatch("/foo/bar", "/foo/ba*");
assertMatch("/foo/bar/baz", "/foo/*");
assertMatch("/foo/bar/baz", "/foo/ba*");
assertMatch("/foo/bar/baz", "/foo/*/*");
assertMatch("/foo/bar/baz", "/foo/*/b*");
assertNotMatch("/foobar", "/foo/*");
assertMatchWithParams("/foo/bar/baz", "/foo[/{var}]/*", "var", "bar");
assertMatchWithParams("/foo/bar/baz", "/foo/*[/{var}]", "var", "baz");
}

@Test
public void testOptionals() throws Exception {
assertMatch("/foo/bar", "/foo[/bar]");
Expand Down