Skip to content

Commit

Permalink
Turn NEXT_PUBLIC_REFLECT_SERVER into a template (😳).
Browse files Browse the repository at this point in the history
  • Loading branch information
aboodman committed Feb 1, 2024
1 parent 8533c75 commit 39e131c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/util/host.ts
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
export const reflectServer = process.env.NEXT_PUBLIC_REFLECT_SERVER ?? "";
export const reflectServer = process.env.NEXT_PUBLIC_REFLECT_SERVER
? applyTemplate(process.env.NEXT_PUBLIC_REFLECT_SERVER)
: "";

function applyTemplate(template: string) {
const f = new Function(
"NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF",
`return \`${template}\``
);
const branchName = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF ?? "";
return f(branchName.replace(/\//g, "-"));
}

0 comments on commit 39e131c

Please sign in to comment.