Skip to content

Commit

Permalink
Fix type casting of boolean env var (directus#6190)
Browse files Browse the repository at this point in the history
  • Loading branch information
rijkvanzanten authored Jun 10, 2021
1 parent 4ac610c commit 31fbb5f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions api/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,21 @@ function processValues(env: Record<string, any>) {
// - boolean values to boolean
// - 'null' to null
// - number values (> 0 <= Number.MAX_SAFE_INTEGER) to number
if (value === 'true' || value === 'false') {
env[key] = !!value;
if (value === 'true') {
env[key] = true;
continue;
}

if (value === 'false') {
env[key] = false;
continue;
}

if (value === 'null') {
env[key] = null;
continue;
}

if (
String(value).startsWith('0') === false &&
isNaN(value) === false &&
Expand Down

0 comments on commit 31fbb5f

Please sign in to comment.