Commit 900a19ed authored by Clement Ho's avatar Clement Ho

Merge branch 'winh-fix-sprintf-eslint' into 'master'

Fix linting errors in sprintf

See merge request gitlab-org/gitlab-ce!14664
parents da9d42f2 dae78a55
...@@ -12,15 +12,15 @@ import _ from 'underscore'; ...@@ -12,15 +12,15 @@ import _ from 'underscore';
@see https://gitlab.com/gitlab-org/gitlab-ce/issues/37992 @see https://gitlab.com/gitlab-org/gitlab-ce/issues/37992
**/ **/
export default (input, parameters, escapeParameters = true) => { export default (input, parameters, escapeParameters = true) => {
let output = input; let output = input;
if (parameters) { if (parameters) {
Object.keys(parameters).forEach((parameterName) => { Object.keys(parameters).forEach((parameterName) => {
const parameterValue = parameters[parameterName]; const parameterValue = parameters[parameterName];
const escapedParameterValue = escapeParameters ? _.escape(parameterValue) : parameterValue; const escapedParameterValue = escapeParameters ? _.escape(parameterValue) : parameterValue;
output = output.replace(new RegExp(`%{${parameterName}}`, 'g'), escapedParameterValue); output = output.replace(new RegExp(`%{${parameterName}}`, 'g'), escapedParameterValue);
}); });
} }
return output; return output;
} };
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