Skip to content

Commit

Permalink
Fix setQueryString issue from #5954
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gregw committed Feb 17, 2021
1 parent 7769f61 commit 3d19679
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Expand Up @@ -90,13 +90,15 @@ public String apply(String target, HttpServletRequest request, HttpServletRespon
@Override
public void applyURI(Request request, String oldURI, String newURI) throws IOException
{
String queryString = request.getQueryString();
if (_query == null)
{
request.setURIPathQuery(newURI);
if (queryString != null)
request.setQueryString(queryString);
}
else
{
String queryString = request.getQueryString();
if (queryString != null)
queryString = queryString + "&" + _query;
else
Expand Down
Expand Up @@ -29,7 +29,7 @@
public class RewritePatternRuleTest extends AbstractRuleTestCase
{
// TODO: Parameterize
private String[][] _tests =
private final String[][] _tests =
{
{"/foo/bar", "/", "/replace"},
{"/foo/bar", "/*", "/replace/foo/bar"},
Expand Down Expand Up @@ -98,8 +98,8 @@ public void testRequestWithQueryString() throws IOException
assertThat("result matches expected", result, is(replacement));

rewritePatternRule.applyURI(_request, null, result);
assertThat("queryString matches expected", _request.getQueryString(), is(queryString));
assertThat("request URI matches expected", _request.getRequestURI(), is(replacement));
assertThat("queryString matches expected", _request.getQueryString(), is(queryString));
}

@Test
Expand Down

0 comments on commit 3d19679

Please sign in to comment.