From aa6e870b578a4917b28fd5fe6f39ccc359859aca Mon Sep 17 00:00:00 2001 From: "John Barton (joho)" Date: Wed, 31 Jul 2013 12:10:31 +1000 Subject: [PATCH] Red, green, rinse repeat. --- godotenv.go | 2 +- godotenv_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/godotenv.go b/godotenv.go index 62ab57d..04c4414 100644 --- a/godotenv.go +++ b/godotenv.go @@ -83,7 +83,7 @@ func parseLine(line string) (key string, value string, err error) { segmentsBetweenHashes := strings.Split(value, "#") value = segmentsBetweenHashes[0] // open quote in leftmost segment - if strings.Count(value, "\"") == 1 { + if strings.Count(value, "\"") == 1 || strings.Count(value, "'") == 1 { value = value + "#" + segmentsBetweenHashes[1] } } diff --git a/godotenv_test.go b/godotenv_test.go index d748538..417a677 100644 --- a/godotenv_test.go +++ b/godotenv_test.go @@ -89,6 +89,7 @@ func TestParsing(t *testing.T) { // it 'allows # in quoted value' do // expect(env('foo="bar#baz" # comment')).to eql('foo' => 'bar#baz') parseAndCompare(t, "FOO=\"bar#baz\" # comment", "FOO", "bar#baz") + parseAndCompare(t, "FOO='bar#baz' # comment", "FOO", "bar#baz") // it 'ignores comment lines' do // expect(env("\n\n\n # HERE GOES FOO \nfoo=bar")).to eql('foo' => 'bar')