Skip to content

Commit

Permalink
Merge pull request #1740 from dilanSachi/fix-query-param-bug-7.x
Browse files Browse the repository at this point in the history
[7.x] Update query param resolving logic
  • Loading branch information
dilanSachi authored Aug 10, 2023
2 parents ce96966 + 179b5a1 commit bbf9cc9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,9 @@ function testQueryParamBindingCase16() returns error? {
[map<json>, string[]] resPayload = check resourceQueryParamBindingClient->/query/case16(query1 = string`{"name":"John"%2C "age":37}`, query2 = strVals);
test:assertEquals(resPayload, [{"name":"John", "age":37}, strVals]);
}

@test:Config {}
function testNoQueryParamBindingCase19() returns error? {
map<string[]> resPayload = check resourceQueryParamBindingClient->/query/case19;
test:assertEquals(resPayload, {});
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ service /query on resourceParamBindingListener {
resource function get case16(map<json> query1, string[] query2) returns [map<json>, string[]] {
return [query1, query2];
}

resource function get case19(http:Request req) returns map<string[]> {
return req.getQueryParams();
}
}

service /header on resourceParamBindingListener {
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ This file contains all the notable changes done to the Ballerina HTTP package th
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Fixed

- [Fix returning an empty query param even without any query params in the request](https://github.com/ballerina-platform/ballerina-standard-library/issues/4705)

## [2.9.1] - 2023-08-08

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import static io.ballerina.stdlib.http.api.HttpConstants.AUTHORIZATION_HEADER;
import static io.ballerina.stdlib.http.api.HttpConstants.BEARER_AUTHORIZATION_HEADER;
import static io.ballerina.stdlib.http.api.HttpConstants.DEFAULT_HOST;
import static io.ballerina.stdlib.http.api.HttpConstants.EMPTY;
import static io.ballerina.stdlib.http.api.HttpConstants.JWT_DECODER_CLASS_NAME;
import static io.ballerina.stdlib.http.api.HttpConstants.JWT_DECODE_METHOD_NAME;
import static io.ballerina.stdlib.http.api.HttpConstants.JWT_INFORMATION;
Expand Down Expand Up @@ -197,7 +196,7 @@ private static String[] extractRawPathAndQuery(String uriWithoutMatrixParams) {
String[] rawPathAndQuery = new String[2];
String[] splittedUri = uriWithoutMatrixParams.split(QUERY_STRING_SEPARATOR);
rawPathAndQuery[0] = splittedUri[0];
rawPathAndQuery[1] = splittedUri.length > 1 ? splittedUri[1] : EMPTY;
rawPathAndQuery[1] = splittedUri.length > 1 ? splittedUri[1] : null;
return rawPathAndQuery;
}

Expand Down

0 comments on commit bbf9cc9

Please sign in to comment.