diff --git a/godotenv.go b/godotenv.go index cd10cab..7cc4d06 100644 --- a/godotenv.go +++ b/godotenv.go @@ -234,7 +234,7 @@ func parseValue(value string) string { last := string(value[len(value)-1:]) if first == last && strings.ContainsAny(first, `"'`) { // pull the quotes off the edges - value = strings.Trim(value, `"'`) + value = value[1 : len(value)-1] // handle escapes escapeRegex := regexp.MustCompile(`\\.`) value = escapeRegex.ReplaceAllStringFunc(value, func(match string) string { diff --git a/godotenv_test.go b/godotenv_test.go index bd4b7cb..9d7d884 100644 --- a/godotenv_test.go +++ b/godotenv_test.go @@ -199,6 +199,9 @@ func TestParsing(t *testing.T) { // parses escaped double quotes parseAndCompare(t, `FOO="escaped\"bar"`, "FOO", `escaped"bar`) + // parses single quotes inside double quotes + parseAndCompare(t, `FOO="'d'"`, "FOO", `'d'`) + // parses yaml style options parseAndCompare(t, "OPTION_A: 1", "OPTION_A", "1")