forked from coop-cloud-mirrors/godotenv
Merge branch 'master' into ignore-leading-whitespace
This commit is contained in:
commit
61baafa627
@ -258,6 +258,9 @@ func parseLine(line string, envMap map[string]string) (key string, value string,
|
|||||||
}
|
}
|
||||||
key = strings.TrimSpace(key)
|
key = strings.TrimSpace(key)
|
||||||
|
|
||||||
|
re := regexp.MustCompile(`^\s*(?:export\s+)?(.*?)\s*$`)
|
||||||
|
key = re.ReplaceAllString(splitString[0], "$1")
|
||||||
|
|
||||||
// Parse the value
|
// Parse the value
|
||||||
value = parseValue(splitString[1], envMap)
|
value = parseValue(splitString[1], envMap)
|
||||||
return
|
return
|
||||||
|
@ -313,6 +313,13 @@ func TestParsing(t *testing.T) {
|
|||||||
// parses export keyword
|
// parses export keyword
|
||||||
parseAndCompare(t, "export OPTION_A=2", "OPTION_A", "2")
|
parseAndCompare(t, "export OPTION_A=2", "OPTION_A", "2")
|
||||||
parseAndCompare(t, `export OPTION_B='\n'`, "OPTION_B", "\\n")
|
parseAndCompare(t, `export OPTION_B='\n'`, "OPTION_B", "\\n")
|
||||||
|
parseAndCompare(t, "export exportFoo=2", "exportFoo", "2")
|
||||||
|
parseAndCompare(t, "exportFOO=2", "exportFOO", "2")
|
||||||
|
parseAndCompare(t, "export_FOO =2", "export_FOO", "2")
|
||||||
|
parseAndCompare(t, "export.FOO= 2", "export.FOO", "2")
|
||||||
|
parseAndCompare(t, "export\tOPTION_A=2", "OPTION_A", "2")
|
||||||
|
parseAndCompare(t, " export OPTION_A=2", "OPTION_A", "2")
|
||||||
|
parseAndCompare(t, "\texport OPTION_A=2", "OPTION_A", "2")
|
||||||
|
|
||||||
// it 'expands newlines in quoted strings' do
|
// it 'expands newlines in quoted strings' do
|
||||||
// expect(env('FOO="bar\nbaz"')).to eql('FOO' => "bar\nbaz")
|
// expect(env('FOO="bar\nbaz"')).to eql('FOO' => "bar\nbaz")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user