forked from coop-cloud-mirrors/godotenv
Version 1.4.0 allowed hyphen "-" to be in environment variable names, after 1.4.0 this resulted in a parsing error which breaks backwards compatibility. Added back in hyphen support in variable names with associated test cases.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
OPTION_A=abc
|
||||
OPTION-B=def
|
||||
|
||||
@@ -184,6 +184,16 @@ func TestLoadEqualsEnv(t *testing.T) {
|
||||
loadEnvAndCompareValues(t, Load, envFileName, expectedValues, noopPresets)
|
||||
}
|
||||
|
||||
func TestLoadHyphenEnv(t *testing.T) {
|
||||
envFileName := "fixtures/hyphen.env"
|
||||
expectedValues := map[string]string{
|
||||
"OPTION_A": "abc",
|
||||
"OPTION-B": "def",
|
||||
}
|
||||
|
||||
loadEnvAndCompareValues(t, Load, envFileName, expectedValues, noopPresets)
|
||||
}
|
||||
|
||||
func TestLoadQuotedEnv(t *testing.T) {
|
||||
envFileName := "fixtures/quoted.env"
|
||||
expectedValues := map[string]string{
|
||||
|
||||
@@ -96,8 +96,8 @@ loop:
|
||||
break loop
|
||||
case '_':
|
||||
default:
|
||||
// variable name should match [A-Za-z0-9_.]
|
||||
if unicode.IsLetter(rchar) || unicode.IsNumber(rchar) || rchar == '.' {
|
||||
// variable name should match [A-Za-z0-9_.-]
|
||||
if unicode.IsLetter(rchar) || unicode.IsNumber(rchar) || rchar == '.' || rchar == '-' {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user