@@ -65,10 +65,19 @@ export function trustedReplaceArgument(
6565 const logPrefix = safe . makeLogPrefix ( 'trusted-replace-argument' , propChain , argposRaw , argraw ) ;
6666 const argoffset = parseInt ( argposRaw , 10 ) || 0 ;
6767 const extraArgs = safe . getExtraArgs ( Array . from ( arguments ) , 3 ) ;
68- const replacer = argraw . startsWith ( 'repl:/' ) &&
69- parseReplaceFn ( argraw . slice ( 5 ) ) || undefined ;
70- const value = replacer === undefined &&
71- validateConstantFn ( true , argraw , extraArgs ) ;
68+ let replacer ;
69+ if ( argraw . startsWith ( 'repl:/' ) ) {
70+ const parsed = parseReplaceFn ( argraw . slice ( 5 ) ) ;
71+ if ( parsed === undefined ) { return ; }
72+ replacer = arg => `${ arg } ` . replace ( replacer . re , replacer . replacement ) ;
73+ } else if ( argraw . startsWith ( 'add:' ) ) {
74+ const delta = parseFloat ( argraw . slice ( 4 ) ) ;
75+ if ( isNaN ( delta ) ) { return ; }
76+ replacer = arg => Number ( arg ) + delta ;
77+ } else {
78+ const value = validateConstantFn ( true , argraw , extraArgs ) ;
79+ replacer = ( ) => value ;
80+ }
7281 const reCondition = extraArgs . condition
7382 ? safe . patternToRegex ( extraArgs . condition )
7483 : / ^ / ;
@@ -100,9 +109,7 @@ export function trustedReplaceArgument(
100109 return context . reflect ( ) ;
101110 }
102111 }
103- const argAfter = replacer && typeof argBefore === 'string'
104- ? argBefore . replace ( replacer . re , replacer . replacement )
105- : value ;
112+ const argAfter = replacer ( argBefore ) ;
106113 if ( argAfter !== argBefore ) {
107114 setArg ( context , argAfter ) ;
108115 safe . uboLog ( logPrefix , `Replaced argument:\nBefore: ${ JSON . stringify ( argBefore ) } \nAfter: ${ argAfter } ` ) ;
0 commit comments