Skip to content

Commit

Permalink
fix: [CI-10905]: fixed the key name with '-'
Browse files Browse the repository at this point in the history
  • Loading branch information
sahithibanda01 committed Mar 26, 2024
1 parent 7765d9d commit 52821d0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions fixtures/exported.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export OPTION_A=2
export OPTION_B='\n'
export OPTION-C=123#12
17 changes: 9 additions & 8 deletions godotenv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func TestLoadExportedEnv(t *testing.T) {
expectedValues := map[string]string{
"OPTION_A": "2",
"OPTION_B": "\\n",
"OPTION-C": "123#12",
}

loadEnvAndCompareValues(t, Load, envFileName, expectedValues, noopPresets)
Expand Down Expand Up @@ -582,42 +583,42 @@ func TestWhitespace(t *testing.T) {
}{
"Leading whitespace": {
input: " A=a\n",
key: "A",
key: "A",
value: "a",
},
"Leading tab": {
input: "\tA=a\n",
key: "A",
key: "A",
value: "a",
},
"Leading mixed whitespace": {
input: " \t \t\n\t \t A=a\n",
key: "A",
key: "A",
value: "a",
},
"Leading whitespace before export": {
input: " \t\t export A=a\n",
key: "A",
key: "A",
value: "a",
},
"Trailing whitespace": {
input: "A=a \t \t\n",
key: "A",
key: "A",
value: "a",
},
"Trailing whitespace with export": {
input: "export A=a\t \t \n",
key: "A",
key: "A",
value: "a",
},
"No EOL": {
input: "A=a",
key: "A",
key: "A",
value: "a",
},
"Trailing whitespace with no EOL": {
input: "A=a ",
key: "A",
key: "A",
value: "a",
},
}
Expand Down
2 changes: 1 addition & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ loop:
case '_':
default:
// variable name should match [A-Za-z0-9_.]
if unicode.IsLetter(rchar) || unicode.IsNumber(rchar) || rchar == '.' {
if unicode.IsLetter(rchar) || unicode.IsNumber(rchar) || rchar == '.' || rchar == '-' {
continue
}

Expand Down

0 comments on commit 52821d0

Please sign in to comment.