fix: cleanr body and formData in curl import

This commit is contained in:
Udhay-Adithya
2025-09-27 18:13:35 +05:30
parent 86f35755eb
commit 34f2ae6178

View File

@@ -416,15 +416,18 @@ class ChatViewmodel extends StateNotifier<ChatState> {
final withEnvUrl = await _maybeSubstituteBaseUrl(url, baseUrl);
if (action.field == 'apply_to_selected') {
if (requestId == null) return;
final replacingBody =
(formFlag || formData.isNotEmpty) ? '' : (body ?? '');
final replacingFormData =
formData.isEmpty ? const <FormDataModel>[] : formData;
collection.update(
method: method,
url: withEnvUrl,
headers: headers,
isHeaderEnabledList: List<bool>.filled(headers.length, true),
body: body,
body: replacingBody,
bodyContentType: bodyContentType,
formData: formData.isEmpty ? null : formData,
// Wipe existing parameters and authentication to ensure clean state
formData: replacingFormData,
params: const [],
isParamEnabledList: const [],
authModel: null,
@@ -895,14 +898,19 @@ class ChatViewmodel extends StateNotifier<ChatState> {
final withEnvUrl = await _maybeSubstituteBaseUrl(url, baseUrl);
if (action.field == 'apply_to_selected') {
if (requestId == null) return;
// Replacement semantics: ensure previous body/formData are cleared if absent in cURL
final replacingBody =
(formFlag || formData.isNotEmpty) ? '' : (body ?? '');
final replacingFormData =
formData.isEmpty ? const <FormDataModel>[] : formData;
collection.update(
method: method,
url: withEnvUrl,
headers: headers,
isHeaderEnabledList: List<bool>.filled(headers.length, true),
body: body,
body: replacingBody,
bodyContentType: bodyContentType,
formData: formData.isEmpty ? null : formData,
formData: replacingFormData,
// Wipe existing parameters and authentication to ensure clean state
params: const [],
isParamEnabledList: const [],