mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-07 22:18:33 +00:00
fix: handle falsy values in Postman environment and collection variables (#4924)
* fix: handle falsy values in Postman environment and collection variables * Updated the `postman-env-to-bruno-env` and `postman-to-bruno` converters to handle cases where variable keys or values are falsy, ensuring they default to empty strings. * Added unit tests to verify the correct handling of falsy values in both environment and collection variables. * fix: filter out null/undefined keys and values in Postman variable imports * Updated the `postman-env-to-bruno-env` and `postman-to-bruno` converters to filter out variables with null keys and values during import. * Removed redundant test cases for empty variables in the corresponding unit tests.
This commit is contained in:
@@ -6,14 +6,14 @@ const isSecret = (type) => {
|
||||
return type === 'secret';
|
||||
};
|
||||
|
||||
const importPostmanEnvironmentVariables = (brunoEnvironment, values) => {
|
||||
const importPostmanEnvironmentVariables = (brunoEnvironment, values = []) => {
|
||||
brunoEnvironment.variables = brunoEnvironment.variables || [];
|
||||
|
||||
each(values, (i) => {
|
||||
each(values.filter(i => !(i.key == null && i.value == null)), (i) => {
|
||||
const brunoEnvironmentVariable = {
|
||||
uid: uuid(),
|
||||
name: i.key.replace(invalidVariableCharacterRegex, '_'),
|
||||
value: i.value,
|
||||
name: (i.key ?? '').replace(invalidVariableCharacterRegex, '_'),
|
||||
value: i.value ?? '',
|
||||
enabled: i.enabled,
|
||||
secret: isSecret(i.type)
|
||||
};
|
||||
|
||||
@@ -119,10 +119,10 @@ const importScriptsFromEvents = (events, requestObject) => {
|
||||
};
|
||||
|
||||
const importCollectionLevelVariables = (variables, requestObject) => {
|
||||
const vars = variables.map((v) => ({
|
||||
const vars = variables.filter(v => !(v.key == null && v.value == null)).map((v) => ({
|
||||
uid: uuid(),
|
||||
name: v.key.replace(invalidVariableCharacterRegex, '_'),
|
||||
value: v.value,
|
||||
name: (v.key ?? '').replace(invalidVariableCharacterRegex, '_'),
|
||||
value: v.value ?? '',
|
||||
enabled: true
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user