Skip to content
Snippets Groups Projects
Commit ec89e7f1 authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Use new Function instead of eval.

parent b1c21ccb
No related branches found
No related tags found
No related merge requests found
......@@ -80,14 +80,21 @@
export function newParameterRepositoryRawUrl(
metadata: Metadata,
// Template below uses branch, group, project & path variables.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
{ branch, group, project, rawUrlTemplate }: SessionOpenFiscaRepository,
parameter: Parameter,
): string | undefined {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const path = `${metadata.parameters_dir}/${parameter.file_path}`
return eval("`" + rawUrlTemplate + "`")
// Can't use:
// return eval("`" + rawUrlTemplate + "`")
// because using direct eval with a bundler is not recommended and may cause problems
// (more info: https://esbuild.github.io/link/direct-eval)
return new Function(
"branch",
"group",
"project",
"path",
"`" + rawUrlTemplate + "`",
)(branch, group, project, path)
}
</script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment