Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -84,7 +84,7 @@ public Set<String> getVariables() {
// possible fallback
// /hello/{foo}/{foo1}/bar
Set<String> hashSet = new TreeSet<>();
Matcher matcher = Pattern.compile("\\{(\\w+)}").matcher(this.path);
Matcher matcher = Pattern.compile("\\{!?(\\w+)}").matcher(this.path);
while(matcher.find()){
hashSet.add(matcher.group(1));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* @author Daniel Espendiller <daniel@espendiller.net>
*/
public class StubIndexedRoute implements RouteInterface, Serializable{
public class StubIndexedRoute implements RouteInterface, Serializable {

@NotNull
private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void testIndexNullable() {

@Test
public void testControllerNullable() {
assertEquals(null, new Route("foo", new HashSet<>(), new HashMap<String, String>() {{
assertNull(new Route("foo", new HashSet<>(), new HashMap<String, String>() {{
put("_controller", null);
}}, new HashMap<>(), new ArrayList<>()).getController());

Expand All @@ -47,10 +47,24 @@ public void testControllerNullable() {
@Test
public void testPathVariables() {
StubIndexedRoute route = new StubIndexedRoute("foobar");
route.setPath("/foo/{foo}/{foobar}/bar");
route.setPath("/foo/{foo}/{foobar}/{#foo1}/{|foo2}/bar");

assertTrue("foobar",
new Route(route).getVariables().containsAll(Arrays.asList("foo", "foobar"))
Set<String> variables = new Route(route).getVariables();
assertEquals(2, variables.size());
assertTrue("foobar", variables.containsAll(Arrays.asList("foo", "foobar")));
}

@Test
public void testPathVariablesForDefault() {
StubIndexedRoute route = new StubIndexedRoute("foobar");
route.setPath("/foo/{!foo}/{!foobar}//{Foobar2}bar");

Set<String> variables = new Route(route).getVariables();

assertEquals(3, variables.size());
assertTrue(
"foobar",
variables.containsAll(Arrays.asList("foo", "foobar", "Foobar2"))
);
}
}