Skip to content

Commit

Permalink
feat: Replace the colon to the dot in the env' variables names.
Browse files Browse the repository at this point in the history
  • Loading branch information
CheerlessCloud committed May 30, 2017
1 parent 51f2f64 commit aaa0505
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/env-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ function envParse(options = {}) {
}

const newKey = key.toLowerCase()
.replace(/([:_-])([a-z\d])/g, str => str[1].toUpperCase());
.replace(/:/g, '.')
.replace(/([_-])([a-z\d])/g, str => str[1].toUpperCase());

return [newKey, env[key]];
}));
Expand Down
10 changes: 10 additions & 0 deletions src/env-parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ describe('env-parser', () => {
}).not.to.throw();
});

it('replace ":" symbol with "."', () => {
process.env = {
'REDIS:HASH-ALGO': 'testName',
};

expect(() => {
expect(envParser().has('redis.hashAlgo')).to.be.equal(true);
}).not.to.throw();
});

it('flat keys', () => {
process.env = {
DATABASE_MONGODB_HOST: 'localhost',
Expand Down

0 comments on commit aaa0505

Please sign in to comment.