add example code

This commit is contained in:
Erik Krogh Kristensen
2021-03-17 13:35:16 +01:00
parent 5898b48391
commit dab6a11978

View File

@@ -150,6 +150,11 @@ class StringReplaceCall extends DataFlow::MethodCallNode {
map.hasPropertyWrite(old, any(DataFlow::Node repl | repl.getStringValue() = new))
)
or
// str.replace(regex, match => {
// if (match === 'old') return 'new';
// if (match === 'foo') return 'bar';
// ...
// })
exists(
DataFlow::FunctionNode replacer, ConditionGuardNode guard, EqualityTest test,
DataFlow::Node ret