Cleanup setPathQuery from #5954 (#5981)

Cleanup setPathQuery from #5954 so that it does not retain an old query if the passed string does not contain a query
This commit is contained in:
Greg Wilkins 2021-02-17 18:05:12 +01:00 committed by GitHub
parent 322d1018a7
commit ad6fc62bb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -705,6 +705,7 @@ public interface HttpURI
_path = null;
_decodedPath = null;
_param = null;
_query = null;
if (pathQuery != null)
parse(State.PATH, pathQuery);
return this;

View File

@ -236,6 +236,13 @@ public class HttpURITest
assertEquals("p2", uri.getParam());
assertEquals("name=value", uri.getQuery());
uri = builder.pathQuery("/f%30%30;p0/bar;p1;p2").asImmutable();
assertEquals("http://host:8888/f%30%30;p0/bar;p1;p2", uri.toString());
assertEquals("/f%30%30;p0/bar;p1;p2", uri.getPath());
assertEquals("/f00/bar", uri.getDecodedPath());
assertEquals("p2", uri.getParam());
assertEquals(null, uri.getQuery());
uri = builder.query("other=123456").asImmutable();
assertEquals("http://host:8888/f%30%30;p0/bar;p1;p2?other=123456", uri.toString());
assertEquals("/f%30%30;p0/bar;p1;p2", uri.getPath());