Skip to content

Commit

Permalink
Fixes to backport of #7748
Browse files Browse the repository at this point in the history
+ Updated UriTemplatePathSpec.java

Signed-off-by: Greg Wilkins <gregw@webtide.com>
  • Loading branch information
gregw committed Apr 5, 2022
1 parent bede25a commit 95b2e41
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Expand Up @@ -358,7 +358,7 @@ public String getPathMatch(String path)
Matcher matcher = getMatcher(path);
if (matcher.matches())
{
if (matcher.groupCount() >= 1)
if (_group == PathSpecGroup.PREFIX_GLOB && matcher.groupCount() >= 1)
{
int idx = matcher.start(1);
if (idx > 0)
Expand Down
Expand Up @@ -27,7 +27,9 @@
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Tests for URI Template Path Specs
Expand Down Expand Up @@ -147,6 +149,20 @@ public void testMiddleVarPathSpec()
assertEquals("b", mapped.get("var"), "Spec.pathParams[var]");
}

@Test
public void testPathInfo()
{
UriTemplatePathSpec spec = new UriTemplatePathSpec("/test/{var}");
assertTrue(spec.matches("/test/info"));
assertThat(spec.getPathMatch("/test/info"), equalTo("/test"));
assertThat(spec.getPathInfo("/test/info"), equalTo("info"));

spec = new UriTemplatePathSpec("/{x}/test/{y}");
assertTrue(spec.matches("/try/test/info"));
assertThat(spec.getPathMatch("/try/test/info"), equalTo("/try/test/info"));
assertThat(spec.getPathInfo("/try/test/info"), nullValue());
}

@Test
public void testOneVarPathSpec()
{
Expand Down

0 comments on commit 95b2e41

Please sign in to comment.