forked from coop-cloud-mirrors/godotenv
Merge pull request #2 from mattn/seveal_equals
FOO=BAR= should be "FOO" = "BAR="
This commit is contained in:
commit
3505098f90
@ -138,11 +138,11 @@ func parseLine(line string) (key string, value string, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now split key from value
|
// now split key from value
|
||||||
splitString := strings.Split(line, "=")
|
splitString := strings.SplitN(line, "=", 2)
|
||||||
|
|
||||||
if len(splitString) != 2 {
|
if len(splitString) != 2 {
|
||||||
// try yaml mode!
|
// try yaml mode!
|
||||||
splitString = strings.Split(line, ":")
|
splitString = strings.SplitN(line, ":", 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(splitString) != 2 {
|
if len(splitString) != 2 {
|
||||||
|
@ -151,6 +151,10 @@ func TestParsing(t *testing.T) {
|
|||||||
// expect(env('FOO.BAR=foobar')).to eql('FOO.BAR' => 'foobar')
|
// expect(env('FOO.BAR=foobar')).to eql('FOO.BAR' => 'foobar')
|
||||||
parseAndCompare(t, "FOO.BAR=foobar", "FOO.BAR", "foobar")
|
parseAndCompare(t, "FOO.BAR=foobar", "FOO.BAR", "foobar")
|
||||||
|
|
||||||
|
// it 'parses varibales with several "=" in the value' do
|
||||||
|
// expect(env('FOO=foobar=')).to eql('FOO' => 'foobar=')
|
||||||
|
parseAndCompare(t, "FOO=foobar=", "FOO", "foobar=")
|
||||||
|
|
||||||
// it 'strips unquoted values' do
|
// it 'strips unquoted values' do
|
||||||
// expect(env('foo=bar ')).to eql('foo' => 'bar') # not 'bar '
|
// expect(env('foo=bar ')).to eql('foo' => 'bar') # not 'bar '
|
||||||
parseAndCompare(t, "FOO=bar ", "FOO", "bar")
|
parseAndCompare(t, "FOO=bar ", "FOO", "bar")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user