Skip to content

Commit

Permalink
Fix bug with not having nested env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
pksunkara committed Jul 20, 2023
1 parent ca2c7f3 commit f63bba4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,13 @@ function extractNested(properties, data) {
key.startsWith(`${name}_`),
);

if (possibles.length > 0) {
data[name] = possibles.reduce(
(acc, key) => ({
...acc,
[key.replace(`${name}_`, '')]: data[key],
}),
{},
);
}
data[name] = possibles.reduce(
(acc, key) => ({
...acc,
[key.replace(`${name}_`, '')]: data[key],
}),
{},
);

if (propSchema.properties) {
propSchema.additionalProperties = false;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nested-env-schema",
"version": "1.0.1",
"version": "1.0.2",
"description": "Validate & extract your env variables using nested JSON schema, Ajv and dotenv",
"main": "lib/index.js",
"types": "types/index.d.ts",
Expand Down

0 comments on commit f63bba4

Please sign in to comment.