Commit cc5c3f4f authored by Vitaly Slobodin's avatar Vitaly Slobodin

Merge branch '330740-use-map-instead-of-object-in-sprintf' into 'master'

Use map in sprintf instead of bracket notation

See merge request gitlab-org/gitlab!62280
parents 7f44bde5 c9db4820
......@@ -15,8 +15,10 @@ export default (input, parameters, escapeParameters = true) => {
let output = input;
if (parameters) {
Object.keys(parameters).forEach((parameterName) => {
const parameterValue = parameters[parameterName];
const mappedParameters = new Map(Object.entries(parameters));
mappedParameters.forEach((key, parameterName) => {
const parameterValue = mappedParameters.get(parameterName);
const escapedParameterValue = escapeParameters ? escape(parameterValue) : parameterValue;
output = output.replace(new RegExp(`%{${parameterName}}`, 'g'), escapedParameterValue);
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment