Skip to content

Commit 5619b62

Browse files
committed
ignore case in prefix
1 parent 71d7d15 commit 5619b62

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

lib/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var env = exports.env = function (prefix, env) {
4444
var obj = {}
4545
var l = prefix.length
4646
for(var k in env) {
47-
if(k.toLowerCase().indexOf(prefix) === 0) {
47+
if(k.toLowerCase().indexOf(prefix.toLowerCase()) === 0) {
4848

4949
var keypath = k.substring(l).split('__')
5050

test/nested-env-vars.js

+25-21
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,28 @@ process.env[n+'___z__i__'] = 9999
2323
// should ignore case for config name section.
2424
process.env[N+'_test_upperCase'] = 187
2525

26-
var config = require('../')(n, {
27-
option: true
28-
})
29-
30-
console.log('\n\n------ nested-env-vars ------\n',config)
31-
32-
assert.equal(config.option, true)
33-
assert.equal(config.someOpt.a, 42)
34-
assert.equal(config.someOpt.x, 99)
35-
// Should not override `a` once it's been set
36-
assert.equal(config.someOpt.a/*.b*/, 42)
37-
// Should not override `x` once it's been set
38-
assert.equal(config.someOpt.x/*.y*/, 99)
39-
assert.equal(config.someOpt.z, 186577)
40-
// Should not override `z` once it's been set
41-
assert.equal(config.someOpt.z/*.x*/, 186577)
42-
assert.equal(config.someOpt.w.w, 18629)
43-
assert.equal(config.z.i, 9999)
44-
45-
assert.equal(config.test_upperCase, 187)
46-
26+
function testPrefix(prefix) {
27+
var config = require('../')(prefix, {
28+
option: true
29+
})
30+
31+
console.log('\n\n------ nested-env-vars ------\n',{prefix: prefix}, '\n', config);
32+
33+
assert.equal(config.option, true)
34+
assert.equal(config.someOpt.a, 42)
35+
assert.equal(config.someOpt.x, 99)
36+
// Should not override `a` once it's been set
37+
assert.equal(config.someOpt.a/*.b*/, 42)
38+
// Should not override `x` once it's been set
39+
assert.equal(config.someOpt.x/*.y*/, 99)
40+
assert.equal(config.someOpt.z, 186577)
41+
// Should not override `z` once it's been set
42+
assert.equal(config.someOpt.z/*.x*/, 186577)
43+
assert.equal(config.someOpt.w.w, 18629)
44+
assert.equal(config.z.i, 9999)
45+
46+
assert.equal(config.test_upperCase, 187)
47+
}
48+
49+
testPrefix(n);
50+
testPrefix(N);

0 commit comments

Comments
 (0)