Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPG-488: Fix issue with Performance query variable interpolation #1038

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/datasources/perf-ds/queries/interpolate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,14 @@ const replaceQueryValueWithVariables = (queryValue: any, variables: Interpolatio
}

// check for '$variableName' syntax
const regexVarName = '\\$' + variable.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
// we add word boundary at the end so we don't have spurious partial matches on variables
// having same beginning portion of name
let regexVarName = '\\$' + variable.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
regexVarName = regexVarName + '\\b'

interpolatedValue = interpolatedValue.replace(new RegExp(regexVarName, 'g'), variableValue)

// check for ${var} with optional {$var:format} where 'format' must be alphanumeric
// check for ${var} with optional ${var:format} where 'format' must be alphanumeric
const regexWithBracesAndFormat = getVariableWithBracesReferencePattern(variable.name)
interpolatedValue = interpolatedValue.replace(new RegExp(regexWithBracesAndFormat, 'g'), variableValue)
})
Expand Down
Loading