mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-16 04:11:29 +00:00
feat/replace unsupported characters in env key during pm import (#4618)
--------- Co-authored-by: sanjai0py <sanjailucifer666@gmail.com>
This commit is contained in:
3
packages/bruno-converters/src/constants/index.js
Normal file
3
packages/bruno-converters/src/constants/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import { invalidVariableCharacterRegex } from './regex';
|
||||
|
||||
export { invalidVariableCharacterRegex };
|
||||
1
packages/bruno-converters/src/constants/regex.js
Normal file
1
packages/bruno-converters/src/constants/regex.js
Normal file
@@ -0,0 +1 @@
|
||||
export const invalidVariableCharacterRegex = /[^\w-.]/g;
|
||||
@@ -1,4 +1,7 @@
|
||||
import each from 'lodash/each';
|
||||
import { invalidVariableCharacterRegex } from '../constants';
|
||||
import { uuid } from '../common';
|
||||
|
||||
const isSecret = (type) => {
|
||||
return type === 'secret';
|
||||
};
|
||||
@@ -8,7 +11,8 @@ const importPostmanEnvironmentVariables = (brunoEnvironment, values) => {
|
||||
|
||||
each(values, (i) => {
|
||||
const brunoEnvironmentVariable = {
|
||||
name: i.key,
|
||||
uid: uuid(),
|
||||
name: i.key.replace(invalidVariableCharacterRegex, '_'),
|
||||
value: i.value,
|
||||
enabled: i.enabled,
|
||||
secret: isSecret(i.type)
|
||||
|
||||
@@ -2,6 +2,7 @@ import get from 'lodash/get';
|
||||
import { validateSchema, transformItemsInCollection, hydrateSeqInCollection, uuid } from '../common';
|
||||
import each from 'lodash/each';
|
||||
import postmanTranslation from './postman-translations';
|
||||
import { invalidVariableCharacterRegex } from '../constants/index';
|
||||
|
||||
const parseGraphQLRequest = (graphqlSource) => {
|
||||
try {
|
||||
@@ -120,7 +121,7 @@ const importScriptsFromEvents = (events, requestObject) => {
|
||||
const importCollectionLevelVariables = (variables, requestObject) => {
|
||||
const vars = variables.map((v) => ({
|
||||
uid: uuid(),
|
||||
name: v.key,
|
||||
name: v.key.replace(invalidVariableCharacterRegex, '_'),
|
||||
value: v.value,
|
||||
enabled: true
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user