Skip to content
This repository was archived by the owner on Jan 12, 2022. It is now read-only.

Commit 61baafa

Browse files
authored
Merge branch 'master' into ignore-leading-whitespace
2 parents 79711ee + 823f94b commit 61baafa

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

godotenv.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ func parseLine(line string, envMap map[string]string) (key string, value string,
258258
}
259259
key = strings.TrimSpace(key)
260260

261+
re := regexp.MustCompile(`^\s*(?:export\s+)?(.*?)\s*$`)
262+
key = re.ReplaceAllString(splitString[0], "$1")
263+
261264
// Parse the value
262265
value = parseValue(splitString[1], envMap)
263266
return

godotenv_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,13 @@ func TestParsing(t *testing.T) {
313313
// parses export keyword
314314
parseAndCompare(t, "export OPTION_A=2", "OPTION_A", "2")
315315
parseAndCompare(t, `export OPTION_B='\n'`, "OPTION_B", "\\n")
316+
parseAndCompare(t, "export exportFoo=2", "exportFoo", "2")
317+
parseAndCompare(t, "exportFOO=2", "exportFOO", "2")
318+
parseAndCompare(t, "export_FOO =2", "export_FOO", "2")
319+
parseAndCompare(t, "export.FOO= 2", "export.FOO", "2")
320+
parseAndCompare(t, "export\tOPTION_A=2", "OPTION_A", "2")
321+
parseAndCompare(t, " export OPTION_A=2", "OPTION_A", "2")
322+
parseAndCompare(t, "\texport OPTION_A=2", "OPTION_A", "2")
316323

317324
// it 'expands newlines in quoted strings' do
318325
// expect(env('FOO="bar\nbaz"')).to eql('FOO' => "bar\nbaz")

0 commit comments

Comments
 (0)