Skip to content

Commit

Permalink
Merge pull request #2 from mattn/seveal_equals
Browse files Browse the repository at this point in the history
FOO=BAR= should be "FOO" = "BAR="
  • Loading branch information
joho committed Nov 18, 2013
2 parents 6e333bd + c0dce90 commit 3505098
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions godotenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ func parseLine(line string) (key string, value string, err error) {
}

// now split key from value
splitString := strings.Split(line, "=")
splitString := strings.SplitN(line, "=", 2)

if len(splitString) != 2 {
// try yaml mode!
splitString = strings.Split(line, ":")
splitString = strings.SplitN(line, ":", 2)
}

if len(splitString) != 2 {
Expand Down
4 changes: 4 additions & 0 deletions godotenv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ func TestParsing(t *testing.T) {
// expect(env('FOO.BAR=foobar')).to eql('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
// expect(env('foo=bar ')).to eql('foo' => 'bar') # not 'bar '
parseAndCompare(t, "FOO=bar ", "FOO", "bar")
Expand Down

0 comments on commit 3505098

Please sign in to comment.