Skip to content

Commit

Permalink
Fixed ClientUri to extract query params when created from a URI.
Browse files Browse the repository at this point in the history
Signed-off-by: Santiago Pericasgeertsen <[email protected]>
  • Loading branch information
spericas committed Aug 2, 2023
1 parent 39b644b commit 21bface
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,11 @@ public ClientUri resolve(URI uri) {
uriBuilder.port(uri.getPort());
}

String uriPath = extractQuery(uri.getPath());
uriBuilder.path(resolvePath(uriBuilder.path().path(), uriPath));
uriBuilder.path(resolvePath(uriBuilder.path().path(), uri.getPath()));

if (uri.getRawQuery() != null) {
query.fromQueryString(uri.getRawQuery());
}

if (uri.getRawFragment() != null) {
uriBuilder.fragment(UriFragment.create(uri.getRawFragment()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.net.URI;

import io.helidon.common.uri.UriPath;

import io.helidon.common.uri.UriQueryWriteable;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
Expand Down Expand Up @@ -59,6 +59,20 @@ void testNonDefaults() {
assertThat(helper.scheme(), is("http"));
}

@Test
void testQueryParams() {
UriQueryWriteable query = UriQueryWriteable.create();
query.fromQueryString("p1=v1&p2=v2&p3=%2F%2Fv3%2F%2F");
ClientUri helper = ClientUri.create(URI.create("http://localhost:8080/loom/quick?" + query.value()));

assertThat(helper.authority(), is("localhost:8080"));
assertThat(helper.host(), is("localhost"));
assertThat(helper.path(), is(UriPath.create("/loom/quick")));
assertThat(helper.port(), is(8080));
assertThat(helper.scheme(), is("http"));
assertThat(helper.query(), is(query));
}

@Test
void testResolvePath() {
ClientUri helper = ClientUri.create(URI.create("http://localhost:8080/loom"));
Expand Down

0 comments on commit 21bface

Please sign in to comment.