WebSocket / Fixing pathmap matching when query parameters are provided

This commit is contained in:
Joakim Erdfelt 2013-09-11 07:21:41 -07:00
parent c49ba7bdcc
commit dc59080fca
3 changed files with 14 additions and 3 deletions

View File

@ -78,6 +78,7 @@ public class WebSocketPathSpecTest
assertEquals("Spec.group",PathSpecGroup.EXACT,spec.getGroup());
assertMatches(spec,"/a");
assertMatches(spec,"/a?type=other");
assertNotMatches(spec,"/a/b");
assertNotMatches(spec,"/a/");

View File

@ -110,7 +110,7 @@ public class WebSocketUpgradeFilter extends ContainerLifeCycle implements Filter
{
HttpServletRequest httpreq = (HttpServletRequest)request;
HttpServletResponse httpresp = (HttpServletResponse)response;
String target = httpreq.getServletPath();
String target = httpreq.getRequestURI();
if (factory.isUpgradeRequest(httpreq,httpresp))
{

View File

@ -159,8 +159,18 @@ public class RegexPathSpec extends PathSpec
}
@Override
public boolean matches(String path)
public boolean matches(final String path)
{
return getMatcher(path).matches();
int idx = path.indexOf('?');
if (idx >= 0)
{
// match only non-query part
return getMatcher(path.substring(0,idx)).matches();
}
else
{
// match entire path
return getMatcher(path).matches();
}
}
}