Skip to content

Commit

Permalink
fix: remove env duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
johackim committed Jun 6, 2023
1 parent 3fb2d8f commit 44ab69a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pages/api/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,15 @@ const putQuery = async (req, res, user) => {
const customEnvStartName = `CUSTOM_ENV_${app.name.toUpperCase().replace(/-/g, '_')}_`;

if (key.startsWith('CUSTOM_ENV_ALL_') || key.startsWith(customEnvStartName)) {
allEnvs.push({
name: key.replace('CUSTOM_ENV_ALL_', '').replace(customEnvStartName, ''),
value: decodeUnicode(process.env[key]),
});
const envName = key.replace('CUSTOM_ENV_ALL_', '').replace(customEnvStartName, '');
const envValue = decodeUnicode(process.env[key]);
const env = allEnvs.find((e) => e.name === envName);

if (env) {
env.value = envValue;
} else {
allEnvs.push({ name: envName, value: envValue });
}
}
});

Expand Down

0 comments on commit 44ab69a

Please sign in to comment.