@@ -1148,7 +1148,7 @@ export class CollectionService {
11481148 return text . replace (
11491149 / ( \{ \{ .* ?\} \} ) | ( [ ^ { } ] + ) / g,
11501150 ( match , insideBraces , outside ) => {
1151- if ( insideBraces ) return insideBraces ;
1151+ if ( insideBraces ) return insideBraces ; // skip {{ }}
11521152 let updated = outside ;
11531153 for ( const variable of generatedVariables ) {
11541154 if ( updated === variable . value ) {
@@ -1180,49 +1180,38 @@ export class CollectionService {
11801180 } ) ) ;
11811181 } ;
11821182
1183- // Main recursive update
1184- const replaceValues = ( obj : any ) : any => {
1185- if ( ! obj || typeof obj !== "object" ) {
1186- return typeof obj === "string" ? replaceOutsideBraces ( obj ) : obj ;
1183+ const newRequest : any = { ...requestItem } ;
1184+ // url
1185+ if ( typeof newRequest . url === "string" ) {
1186+ newRequest . url = replaceOutsideBraces ( newRequest . url ) ;
1187+ }
1188+ // headers
1189+ if ( Array . isArray ( newRequest . headers ) ) {
1190+ newRequest . headers = updateKeyValueArray ( newRequest . headers ) ;
1191+ }
1192+ // queryParams
1193+ if ( Array . isArray ( newRequest . queryParams ) ) {
1194+ newRequest . queryParams = updateKeyValueArray ( newRequest . queryParams ) ;
1195+ }
1196+ // body
1197+ if ( typeof newRequest . body === "object" && newRequest . body !== null ) {
1198+ const updatedBody = { ...newRequest . body } ;
1199+ if ( typeof updatedBody . raw === "string" ) {
1200+ updatedBody . raw = replaceOutsideBraces ( updatedBody . raw ) ;
11871201 }
1188- const newObj : any = Array . isArray ( obj ) ? [ ] : { } ;
1189- for ( const [ key , value ] of Object . entries ( obj ) ) {
1190- if ( key === "url" && typeof value === "string" ) {
1191- newObj [ key ] = replaceOutsideBraces ( value ) ;
1192- } else if ( key === "headers" && Array . isArray ( value ) ) {
1193- newObj [ key ] = updateKeyValueArray ( value ) ;
1194- } else if ( key === "queryParams" && Array . isArray ( value ) ) {
1195- newObj [ key ] = updateKeyValueArray ( value ) ;
1196- } else if (
1197- key === "body" &&
1198- typeof value === "object" &&
1199- value !== null
1200- ) {
1201- const updatedBody = { ...( value as RequestBodyDto ) } ;
1202- if ( typeof updatedBody . raw === "string" ) {
1203- updatedBody . raw = replaceOutsideBraces ( updatedBody . raw ) ;
1204- }
1205- if ( Array . isArray ( updatedBody . urlencoded ) ) {
1206- updatedBody . urlencoded = updateKeyValueArray (
1207- updatedBody . urlencoded ,
1208- ) ;
1209- }
1210- if (
1211- updatedBody . formdata &&
1212- typeof updatedBody . formdata === "object"
1213- ) {
1214- if ( Array . isArray ( updatedBody . formdata . text ) ) {
1215- updatedBody . formdata . text = updateKeyValueArray (
1216- updatedBody . formdata . text ,
1217- ) ;
1218- }
1219- }
1220- newObj [ key ] = updatedBody ;
1202+ if ( Array . isArray ( updatedBody . urlencoded ) ) {
1203+ updatedBody . urlencoded = updateKeyValueArray ( updatedBody . urlencoded ) ;
1204+ }
1205+ if ( updatedBody . formdata && typeof updatedBody . formdata === "object" ) {
1206+ if ( Array . isArray ( updatedBody . formdata . text ) ) {
1207+ updatedBody . formdata . text = updateKeyValueArray (
1208+ updatedBody . formdata . text ,
1209+ ) ;
12211210 }
12221211 }
1223- return newObj ;
1224- } ;
1225- return replaceValues ( requestItem ) ;
1212+ newRequest . body = updatedBody ;
1213+ }
1214+ return newRequest ;
12261215 }
12271216
12281217 public async insertGeneratedVariables (
0 commit comments