mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 02:39:19 +08:00
fix: cleanr body and formData in curl import
This commit is contained in:
@@ -416,15 +416,18 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
|||||||
final withEnvUrl = await _maybeSubstituteBaseUrl(url, baseUrl);
|
final withEnvUrl = await _maybeSubstituteBaseUrl(url, baseUrl);
|
||||||
if (action.field == 'apply_to_selected') {
|
if (action.field == 'apply_to_selected') {
|
||||||
if (requestId == null) return;
|
if (requestId == null) return;
|
||||||
|
final replacingBody =
|
||||||
|
(formFlag || formData.isNotEmpty) ? '' : (body ?? '');
|
||||||
|
final replacingFormData =
|
||||||
|
formData.isEmpty ? const <FormDataModel>[] : formData;
|
||||||
collection.update(
|
collection.update(
|
||||||
method: method,
|
method: method,
|
||||||
url: withEnvUrl,
|
url: withEnvUrl,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
isHeaderEnabledList: List<bool>.filled(headers.length, true),
|
isHeaderEnabledList: List<bool>.filled(headers.length, true),
|
||||||
body: body,
|
body: replacingBody,
|
||||||
bodyContentType: bodyContentType,
|
bodyContentType: bodyContentType,
|
||||||
formData: formData.isEmpty ? null : formData,
|
formData: replacingFormData,
|
||||||
// Wipe existing parameters and authentication to ensure clean state
|
|
||||||
params: const [],
|
params: const [],
|
||||||
isParamEnabledList: const [],
|
isParamEnabledList: const [],
|
||||||
authModel: null,
|
authModel: null,
|
||||||
@@ -895,14 +898,19 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
|||||||
final withEnvUrl = await _maybeSubstituteBaseUrl(url, baseUrl);
|
final withEnvUrl = await _maybeSubstituteBaseUrl(url, baseUrl);
|
||||||
if (action.field == 'apply_to_selected') {
|
if (action.field == 'apply_to_selected') {
|
||||||
if (requestId == null) return;
|
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(
|
collection.update(
|
||||||
method: method,
|
method: method,
|
||||||
url: withEnvUrl,
|
url: withEnvUrl,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
isHeaderEnabledList: List<bool>.filled(headers.length, true),
|
isHeaderEnabledList: List<bool>.filled(headers.length, true),
|
||||||
body: body,
|
body: replacingBody,
|
||||||
bodyContentType: bodyContentType,
|
bodyContentType: bodyContentType,
|
||||||
formData: formData.isEmpty ? null : formData,
|
formData: replacingFormData,
|
||||||
// Wipe existing parameters and authentication to ensure clean state
|
// Wipe existing parameters and authentication to ensure clean state
|
||||||
params: const [],
|
params: const [],
|
||||||
isParamEnabledList: const [],
|
isParamEnabledList: const [],
|
||||||
|
|||||||
Reference in New Issue
Block a user