@@ -2560,14 +2560,15 @@ export class CollectionRequestService {
25602560 private generateBodyVariables ( bodies : any [ ] ) : Record < string , string > {
25612561 if ( bodies . length === 0 ) return { } ;
25622562
2563+ const existingVariablePattern = / \{ \{ ? [ ^ } ] + \} ? \} / ; // pre-existing vars like {{VAR}} or {var}
25632564 const valueFrequencyByKey = new Map < string , Map < string , number > > ( ) ;
25642565 const valueCountByKey : Record < string , number > = { } ;
25652566
25662567 const extractKeyValuePairs = ( obj : any , parentKey = '' ) : Array < [ string , string ] > => {
25672568 const pairs : Array < [ string , string ] > = [ ] ;
25682569
25692570 if ( typeof obj === 'string' ) {
2570- if ( obj . trim ( ) ) pairs . push ( [ parentKey || 'body' , obj . trim ( ) ] ) ;
2571+ if ( obj . trim ( ) && ! existingVariablePattern . test ( obj . trim ( ) ) ) { pairs . push ( [ parentKey || 'body' , obj . trim ( ) ] ) ; }
25712572 } else if ( Array . isArray ( obj ) ) {
25722573 obj . forEach ( ( item ) => pairs . push ( ...extractKeyValuePairs ( item , parentKey ) ) ) ;
25732574 } else if ( typeof obj === 'object' && obj !== null ) {
@@ -2584,7 +2585,7 @@ export class CollectionRequestService {
25842585 // Process urlencoded
25852586 if ( body . urlencoded ) {
25862587 for ( const item of body . urlencoded ) {
2587- if ( item . checked !== false && item . value ?. trim ( ) ) {
2588+ if ( item . checked !== false && item . value ?. trim ( ) && ! existingVariablePattern . test ( item . value ) ) {
25882589 const key = item . key . trim ( ) ;
25892590 const value = item . value . trim ( ) ;
25902591 this . addToFrequencyMap ( key , value , valueFrequencyByKey , valueCountByKey ) ;
@@ -2595,7 +2596,7 @@ export class CollectionRequestService {
25952596 // Process formdata
25962597 if ( body . formdata ?. text ) {
25972598 for ( const item of body . formdata . text ) {
2598- if ( item . checked !== false && item . value ?. trim ( ) ) {
2599+ if ( item . checked !== false && item . value ?. trim ( ) && ! existingVariablePattern . test ( item . value ) ) {
25992600 const key = item . key . trim ( ) ;
26002601 const value = item . value . trim ( ) ;
26012602 this . addToFrequencyMap ( key , value , valueFrequencyByKey , valueCountByKey ) ;
@@ -2618,7 +2619,7 @@ export class CollectionRequestService {
26182619
26192620 // Process other body types (websocket, socketio, graphql)
26202621 [ 'message' , 'event' , 'query' , 'mutation' , 'variables' ] . forEach ( field => {
2621- if ( body [ field ] ?. trim ( ) ) {
2622+ if ( body [ field ] ?. trim ( ) && ! existingVariablePattern . test ( body [ field ] ) ) {
26222623 this . addToFrequencyMap ( field , body [ field ] . trim ( ) , valueFrequencyByKey , valueCountByKey ) ;
26232624 }
26242625 } ) ;
@@ -2659,15 +2660,18 @@ export class CollectionRequestService {
26592660 */
26602661 private generateQueryVariables ( paramGroups : Array < Array < { key : string ; value : string ; checked : boolean } > > ) : Record < string , string > {
26612662 if ( paramGroups . length === 0 ) return { } ;
2663+ const existingVariablePattern = / \{ \{ ? [ ^ } ] + \} ? \} / ; // Matches {{VAR}}, {VAR}
26622664
26632665 const keyValueFrequency = new Map < string , Map < string , number > > ( ) ;
26642666 const keyValueCount : Record < string , number > = { } ;
26652667
26662668 // Count frequencies per key
26672669 for ( const group of paramGroups ) {
26682670 for ( const param of group ) {
2669- if ( param . value ?. trim ( ) ) {
2670- const key = param . key ;
2671+ if ( param . value ?. trim ( ) &&
2672+ ! existingVariablePattern . test ( param . value . trim ( ) ) // skip pre-existing vars
2673+ ) {
2674+ const key = param . key . trim ( ) ;
26712675 const value = param . value . trim ( ) ;
26722676 this . addToFrequencyMap ( key , value , keyValueFrequency , keyValueCount ) ;
26732677 }
@@ -2703,14 +2707,19 @@ export class CollectionRequestService {
27032707 ) : Record < string , string > {
27042708 if ( headerGroups . length === 0 ) return { } ;
27052709
2710+ const existingVariablePattern = / \{ \{ ? [ ^ } ] + \} ? \} / ; // Matches {{VAR}}, {VAR}
2711+
27062712 const keyValueFrequency = new Map < string , Map < string , number > > ( ) ;
27072713 const keyValueCount : Record < string , number > = { } ;
27082714
27092715 // Count frequencies per header key
27102716 for ( const group of headerGroups ) {
27112717 for ( const header of group ) {
2712- if ( header . value ?. trim ( ) ) {
2713- const key = header . key ;
2718+ if (
2719+ header . value ?. trim ( ) &&
2720+ ! existingVariablePattern . test ( header . value . trim ( ) ) // skip pre-existing vars
2721+ ) {
2722+ const key = header . key . trim ( ) ;
27142723 const value = header . value . trim ( ) ;
27152724 this . addToFrequencyMap ( key , value , keyValueFrequency , keyValueCount ) ;
27162725 }
0 commit comments