Fix setQueryString issue from #5954
Rewrite rule depending on probably bug that setURIPathQuery did not actually set query if none was passed. This is a bit of a work around, but further review is needed to see if anything else relied on that behaviour.
This commit is contained in:
parent
7769f61242
commit
3d19679d10
|
@ -90,13 +90,15 @@ public class RewritePatternRule extends PatternRule implements Rule.ApplyURI
|
||||||
@Override
|
@Override
|
||||||
public void applyURI(Request request, String oldURI, String newURI) throws IOException
|
public void applyURI(Request request, String oldURI, String newURI) throws IOException
|
||||||
{
|
{
|
||||||
|
String queryString = request.getQueryString();
|
||||||
if (_query == null)
|
if (_query == null)
|
||||||
{
|
{
|
||||||
request.setURIPathQuery(newURI);
|
request.setURIPathQuery(newURI);
|
||||||
|
if (queryString != null)
|
||||||
|
request.setQueryString(queryString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String queryString = request.getQueryString();
|
|
||||||
if (queryString != null)
|
if (queryString != null)
|
||||||
queryString = queryString + "&" + _query;
|
queryString = queryString + "&" + _query;
|
||||||
else
|
else
|
||||||
|
|
|
@ -29,7 +29,7 @@ import static org.hamcrest.Matchers.is;
|
||||||
public class RewritePatternRuleTest extends AbstractRuleTestCase
|
public class RewritePatternRuleTest extends AbstractRuleTestCase
|
||||||
{
|
{
|
||||||
// TODO: Parameterize
|
// TODO: Parameterize
|
||||||
private String[][] _tests =
|
private final String[][] _tests =
|
||||||
{
|
{
|
||||||
{"/foo/bar", "/", "/replace"},
|
{"/foo/bar", "/", "/replace"},
|
||||||
{"/foo/bar", "/*", "/replace/foo/bar"},
|
{"/foo/bar", "/*", "/replace/foo/bar"},
|
||||||
|
@ -98,8 +98,8 @@ public class RewritePatternRuleTest extends AbstractRuleTestCase
|
||||||
assertThat("result matches expected", result, is(replacement));
|
assertThat("result matches expected", result, is(replacement));
|
||||||
|
|
||||||
rewritePatternRule.applyURI(_request, null, result);
|
rewritePatternRule.applyURI(_request, null, result);
|
||||||
assertThat("queryString matches expected", _request.getQueryString(), is(queryString));
|
|
||||||
assertThat("request URI matches expected", _request.getRequestURI(), is(replacement));
|
assertThat("request URI matches expected", _request.getRequestURI(), is(replacement));
|
||||||
|
assertThat("queryString matches expected", _request.getQueryString(), is(queryString));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue