Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions packages/clerk_auth/lib/src/clerk_api/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,13 @@ class Api with Logging {
.toList(growable: false);
}

dynamic _ensureNotNullOrEmpty(dynamic param) {
if (param case String param) {
return param.trim().orNullIfEmpty;
}
return param;
}

Future<http.Response> _fetch({
required String path,
HttpMethod method = HttpMethod.post,
Expand All @@ -950,9 +957,10 @@ class Api with Logging {
bool withSession = false,
}) async {
final parsedParams = {
for (final entry in (params ?? const {}).entries)
if (entry.value != null) //
entry.key: entry.value,
if (params?.entries case final entries?) //
for (final MapEntry(:key, :value) in entries) //
if (_ensureNotNullOrEmpty(value) case final value?) //
key: value,
...?nullableParams,
};
final queryParams = _queryParams(
Expand Down Expand Up @@ -1021,7 +1029,7 @@ class Api with Logging {
HttpHeaders.contentTypeHeader: method.isGet
? 'application/json'
: 'application/x-www-form-urlencoded',
if (_tokenCache.clientToken.isNotEmpty) //
if (_tokenCache.hasClientToken) //
HttpHeaders.authorizationHeader: _tokenCache.clientToken,
_kClerkAPIVersion: ClerkConstants.clerkApiVersion,
_kXFlutterSDKVersion: ClerkConstants.flutterSdkVersion,
Expand Down