Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
VerKWer committed Sep 23, 2024
1 parent 1de9b80 commit 4b89c88
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,28 @@ public ClientUri skipUriEncoding(boolean skipUriEncoding) {
}

/**
* Resolve the provided URI against this URI.
* Replace {@code this} {@link ClientUri}'s URI with the result of resolving the provided {@link URI} against the
* current one.
*
* @param uri URI to use
* @return updated instance
* @return {@code this} updated instance
*/
public ClientUri resolve(URI uri) {
return resolve(uri, false);
}

/**
* Resolve the provided {@link URI} against {@code this} {@link ClientUri}.
*
* @param uri
* @param keepQueryParameters
* @return {@code this} updated instance
*/
public ClientUri resolve(URI uri, boolean keepQueryParameters) {
if (uri.isAbsolute()) {
this.uriBuilder = UriInfo.builder();
this.query.clear();
if(!keepQueryParameters)
this.query.clear();
}

if (uri.getScheme() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,10 @@ void testResolveQueryParameter() {
assertThat(helper.scheme(), is("https"));
assertThat(helper.query().get("k"), is("v"));
}

@Test
void myTest() throws Exception {
ClientUri helper = ClientUri.create(URI.create("http://localhost:8080/?k=v"));
System.out.println(helper.resolve(URI.create("?a=b")));
}
}

0 comments on commit 4b89c88

Please sign in to comment.