We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 9b810b8 + eabdcbd commit a5de551Copy full SHA for a5de551
3 files changed
system/Config/DotEnv.php
@@ -116,7 +116,8 @@ public function normaliseVariable(string $name, string $value = ''): array
116
$value = trim($value);
117
118
// Sanitize the name
119
- $name = str_replace(['export', '\'', '"'], '', $name);
+ $name = preg_replace('/^export[ \t]++(\S+)/', '$1', $name);
120
+ $name = str_replace(['\'', '"'], '', $name);
121
122
// Sanitize the value
123
$value = $this->sanitizeValue($value);
tests/system/Config/DotEnvTest.php
@@ -55,14 +55,30 @@ public function testReturnsFalseIfCannotFindFile()
55
$this->assertFalse($dotenv->load());
56
}
57
58
- public function testLoadsVars()
+ /**
59
+ * @dataProvider provideLoadVars
60
+ */
61
+ public function testLoadsVars(string $expected, string $varname)
62
{
63
$dotenv = new DotEnv($this->fixturesFolder);
64
$dotenv->load();
- $this->assertSame('bar', getenv('FOO'));
- $this->assertSame('baz', getenv('BAR'));
- $this->assertSame('with spaces', getenv('SPACED'));
65
- $this->assertSame('', getenv('NULL'));
+
66
+ $this->assertSame($expected, getenv($varname));
67
+ }
68
69
+ public function provideLoadVars(): iterable
70
+ {
71
+ yield from [
72
+ ['bar', 'FOO'],
73
+ ['baz', 'BAR'],
74
+ ['with spaces', 'SPACED'],
75
+ ['', 'NULL'],
76
+ ['exported foo', 'char.expo.foo'],
77
+ ['variable', 'character.export.var'],
78
+ ['character', 'char.var'],
79
+ ['imports', 'char.exports'],
80
+ ['banana', 'fruit.export'],
81
+ ];
82
83
84
/**
tests/system/Config/fixtures/.env
@@ -4,6 +4,12 @@ SPACED="with spaces"
4
5
NULL=
6
7
+char.expo.foo="exported foo"
8
+character.export.var=variable
9
+export char.var=character
10
+export char.exports=imports
11
+fruit.export = "banana"
12
13
SimpleConfig.onedeep=baz
14
SimpleConfig.default.name=ci4
15
# Use underscore as separator
0 commit comments