Skip to content

Commit e0822f9

Browse files
authored
fix: use queryParametersAll when building RequestData
1 parent 84f79cf commit e0822f9

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/models/request_data.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class RequestData {
2727

2828
factory RequestData.fromHttpRequest(Request request) {
2929
var params = Map<String, dynamic>();
30-
request.url.queryParameters.forEach((key, value) {
30+
request.url.queryParametersAll.forEach((key, value) {
3131
params[key] = value;
3232
});
3333
String baseUrl = request.url.origin + request.url.path;

test/models/request_data_test.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,23 @@ main() {
6767
equals(
6868
"https://www.google.com/helloworld?key=123ABC&name=Hugo&type=3"));
6969
});
70+
test("can be instantiated from HTTP GET Request with multiple parameters with same key", () {
71+
// Arrange
72+
Uri url = Uri.parse(
73+
"https://www.google.com/helloworld?name=Hugo&type=2&type=3&type=4");
74+
75+
Request request = Request("GET", url);
76+
RequestData requestData;
77+
78+
// Act
79+
requestData = RequestData.fromHttpRequest(request);
80+
81+
// Assert
82+
expect(
83+
requestData.url,
84+
equals(
85+
"https://www.google.com/helloworld?name=Hugo&type=2&type=3&type=4"));
86+
});
7087
test("correctly creates the request URL string", () {
7188
// Arrange
7289
Uri url = Uri.parse(

0 commit comments

Comments
 (0)