Skip to content

Commit aa1db26

Browse files
ndeloofglours
authored andcommitted
Revert "accept dashes in variable names"
This reverts commit be170be. Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 4f02e42 commit aa1db26

File tree

4 files changed

+6
-17
lines changed

4 files changed

+6
-17
lines changed

dotenv/fixtures/special.env

Lines changed: 0 additions & 3 deletions
This file was deleted.

dotenv/godotenv_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -691,14 +691,6 @@ func TestUTF8BOM(t *testing.T) {
691691
loadEnvAndCompareValues(t, Load, envFileName, expectedValues, noopPresets)
692692
}
693693

694-
func TestDash(t *testing.T) {
695-
loadEnvAndCompareValues(t, Load, "fixtures/special.env", map[string]string{
696-
"VAR-WITH-DASHES": "dashes",
697-
"VAR.WITH.DOTS": "dots",
698-
"VAR_WITH_UNDERSCORES": "underscores",
699-
}, noopPresets)
700-
}
701-
702694
func TestGetEnvFromFile(t *testing.T) {
703695
wd := t.TempDir()
704696
f := filepath.Join(wd, ".env")

dotenv/parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ loop:
119119
offset = i + 1
120120
inherited = rune == '\n'
121121
break loop
122-
case '_', '.', '-', '[', ']':
122+
case '_', '.', '[', ']':
123123
default:
124124
// variable name should match [A-Za-z0-9_.-]
125125
if unicode.IsLetter(rune) || unicode.IsNumber(rune) {

dotenv/parser_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ var testInput = `
1313
a=b
1414
a[1]=c
1515
a.propertyKey=d
16-
árvíztűrő-TÜKÖRFÚRÓGÉP=ÁRVÍZTŰRŐ-tükörfúrógép
16+
árvíztűrőTÜKÖRFÚRÓGÉP=ÁRVÍZTŰRŐtükörfúrógép
1717
`
1818

1919
func TestParseBytes(t *testing.T) {
2020
p := newParser()
2121

2222
expectedOutput := map[string]string{
23-
"a": "b",
24-
"a[1]": "c",
25-
"a.propertyKey": "d",
26-
"árvíztűrő-TÜKÖRFÚRÓGÉP": "ÁRVÍZTŰRŐ-tükörfúrógép",
23+
"a": "b",
24+
"a[1]": "c",
25+
"a.propertyKey": "d",
26+
"árvíztűrőTÜKÖRFÚRÓGÉP": "ÁRVÍZTŰRŐtükörfúrógép",
2727
}
2828

2929
out := map[string]string{}

0 commit comments

Comments
 (0)