Skip to content

Commit

Permalink
Fixed query params for lists
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoRB committed Jan 26, 2024
1 parent 5b63469 commit fae634e
Showing 1 changed file with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,20 @@ class DartnessRouterHandler {
} else {
if (param.isPath) {
final pathParam = _getPathParam(request, param);
final value = pathParam.stringToType(param.type);
namedArguments[Symbol(param.name)] = value;
if (pathParam is String) {
final value = pathParam.stringToType(param.type);
namedArguments[Symbol(param.name)] = value;
} else {
namedArguments[Symbol(param.name)] = pathParam;
}
} else {
final String? queryParam = _getQueryParam(request, param);
final value = queryParam?.stringToType(param.type);
namedArguments[Symbol(param.name)] = value;
final Object? queryParam = _getQueryParam(request, param);
if (queryParam is String) {
final value = queryParam.stringToType(param.type);
namedArguments[Symbol(param.name)] = value;
} else {
namedArguments[Symbol(param.name)] = queryParam;
}
}
}
}
Expand Down Expand Up @@ -87,9 +95,15 @@ class DartnessRouterHandler {
);
}

dynamic _getQueryParam(Request request, DartnessParam param) =>
request.url.queryParameters[param.name] ?? param.defaultValue;
Object? _getQueryParam(final Request request, final DartnessParam param) {
final all = request.url.queryParametersAll;
final foundAll = all[param.name];
if (foundAll != null && foundAll.length > 1) {
return all[param.name];
}
return request.url.queryParameters[param.name] ?? param.defaultValue;
}

dynamic _getPathParam(Request request, DartnessParam param) =>
Object? _getPathParam(final Request request, final DartnessParam param) =>
request.params[param.name] ?? param.defaultValue;
}

0 comments on commit fae634e

Please sign in to comment.