Skip to content
Snippets Groups Projects
Commit 92871da5 authored by David Smadja's avatar David Smadja
Browse files

Modify url templates placeholders in env file

parent fe9797c9
No related branches found
No related tags found
No related merge requests found
......@@ -75,8 +75,8 @@ PUBLIC_MATOMO_SUBDOMAINS="*.DOMAIN"
PUBLIC_OPENFISCA_BRANCH="master"
PUBLIC_OPENFISCA_GROUP="openfisca"
PUBLIC_OPENFISCA_PROJECT="openfisca-france"
PUBLIC_OPENFISCA_REPOSITORY_RAW_URL_TEMPLATE="https://raw.githubusercontent.com/${group}/${project}/${branch}/${path}"
PUBLIC_OPENFISCA_REPOSITORY_URL_TEMPLATE="https://github.com/${group}/${project}/blob/${branch}/${path}"
PUBLIC_OPENFISCA_REPOSITORY_RAW_URL_TEMPLATE="https://raw.githubusercontent.com/$<group>/$<project>/$<branch>/$<path>"
PUBLIC_OPENFISCA_REPOSITORY_URL_TEMPLATE="https://github.com/$<group>/$<project>/blob/$<branch>/$<path>"
# URL of portal site (used when clicking on left logo in menu bar)
PUBLIC_PORTAL_URL="https://leximpact.an.fr/"
......
import type { Parameter } from "@openfisca/json-model"
export interface RepositoryConfig {
branch: string
group: string
......@@ -12,40 +11,30 @@ export function newParameterRepositoryRawUrl(
{ branch, group, project, rawUrlTemplate }: RepositoryConfig,
parameter: Parameter,
): string | undefined {
const path = parameter.file_path
const path = parameter.file_path;
if (path === undefined) {
return undefined
return undefined;
}
// 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",
"return `" + rawUrlTemplate + "`",
)(branch, group, project, path)
const url = rawUrlTemplate
.replace("$<group>", group)
.replace("$<project>", project)
.replace("$<branch>", branch)
.replace("$<path>", path);
return url;
}
export function newParameterRepositoryUrl(
{ branch, group, project, urlTemplate }: RepositoryConfig,
parameter: Parameter,
): string | undefined {
const path = parameter.file_path
const path = parameter.file_path;
if (path === undefined) {
return undefined
return undefined;
}
// Can't use:
// return eval("`" + urlTemplate + "`")
// 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",
"return `" + urlTemplate + "`",
)(branch, group, project, path)
const url = urlTemplate
.replace("$<group>", group)
.replace("$<project>", project)
.replace("$<branch>", branch)
.replace("$<path>", path);
return url;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment